Issue when converting XML dateTime to .NET DateTime


I am experiencing an issue when deserializing XML dateTime nodes in ASP.NET in some timezones.
The construct 0001-01-01T00:00:00.0000000+ZZ:ZZ where ZZ:ZZ is the timezone offset for the timezone on the current system should produce a DateTime value equalling the constant DateTime.MinValue when converted.
This works some of the time, such as for the Paris time offset of +1:
(CDate("0001-01-01T00:00:00.0000000+01:00") = DateTime.MinValue) = True

But does not work for Sydney time offset of +10:
(CDate("0001-01-01T00:00:00.0000000+10:00") = DateTime.MinValue) = False

These timezone offsets were checked as being correct by manually checking the number of ticks offset from UTC in the System.Timezone.CurrentTimezone construct.
This can also be done using the following code:
Dim tz As TimeSpan = System.TimeZone.CurrentTimeZone.GetUtcOffset(Now)
If System.TimeZone.CurrentTimeZone.IsDaylightSavingTime(Now) Then
tz = tz.Subtract(System.TimeZone.CurrentTimeZone.GetDaylightChanges(Now.Year).Delta)
End If
The resulting TimeSpan in tz should be the correct offset from UTC for this timezone.
It appears that the conversion from an XML dateTime to a .NET DateTime is in some way erroneous:
Again, when the system's timezone is set to Paris (+1):
CDate("0001-01-01T00:00:00.0000000+01:00") = #12:00:00 AM#
While when the system's timezine is set to Sydney (+10):
CDate("0001-01-01T00:00:00.0000000+10:00") = #1:00:00 AM#
Can anyone explain why this conversion is an hour out for Sydney? And is this problematic for other regions?
8/11/2003 9:21:51 AM 91979 articles. 4 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 45


Similar Artilces:

Convert .NET DateTime format to SQL DateTime format
Hi!!I'd like to know if there is a function to convert the DateTime format used in C# (VS2005) : dd/mm/yyyy HH:mm:ss to the format used in SQL Databases: yyyymmdd HH:mm:ssThanks folks!...

convert an sql datetime column to .net datetime data type in front end...?
I have a field (ldate) in a table that typically displays data in the following format:2007-11-12 20:30:47.000In the front end I want the time and the date separately. But as I try to cast it to a datetime object it is giving me a System.NullReferenceException. What I tried to do was just this: Protected Sub gvTopics_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvTopics.RowDataBound Dim img As Image = gvTopics.FindControl("imgIcon") Dim lbDate, lbTime As Label lbDate = gvTopics.FindControl(...

.NET DateTime and SQL Server DateTime problem
.NET DateTime and SQL Server DateTime problem  I have the following if statement in an SQL stored procedure: IF (@Image = 1 AND @DateTimeUploaded = (SELECT ImageMainDateTime FROM Images WHERE UserID = @UserID))   The value of the @DateTimeUpdated variable was taken from the ImageMainDateTime field when the data was requested by a ASP.NET webpage and is passed back here when that page is submitted so I can compare what the DateTime was when the data was requested with what it is now, in other words I’m doing a concurrency check (I can’t use TimeStamp for many reasons, ...

converting to from offered me some sample code when I signed up with them the only problem is the sample code is in but my page that they type all of their credit card into is <code><%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %> <script language="C#" runat="server"> void Page_Load(Object Src, EventArgs E) { myPage.Text = readHtmlPage(""); } private String readHtmlPage(string url) { ...

Insert datetime, using
Hello there,I got a little code there are inserting a record into my msSQL database..But i cant insert the datetime, for one reason?The problem is in line 7 () where i want to insert DateTime.Now 1 Protected Sub SendPmTilAfviste(ByVal modtager As String, ByVal festID As String) 2 ' Connection 3 Dim conn As SqlConnection = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True") 4 conn.Open() 5 6 ' SQL-kommandoen 7 Dim cm...

convert to/from .NET's System.DateTime?
Is there a module/routine to do this? From .NET Framework SDK documentation: "Time values are measured in 100-nanosecond units called ticks, and a particular date is the number of ticks since 12:00 midnight, January 1, 1 C.E. in the GregorianCalendar calendar. For example, a ticks value of 31241376000000000L represents the date, Friday, January 01, 0100 12:00:00 midnight." Of all the 64bit timestamp I've seen (others include TAI, NTP, PostgreSQL, Firebird, Win32 FILETIME), I've kind of like this one because the range and precision usually "feels right&qu...

Newbie Question
I have a new project which has just started. One of the requirements is to generate XML files. Do I have to create schema files? Does anyone have a tutorial or sample code to help me get started. I have some background using XML, but not in .NET. Thx Mark How to create a new xml file with XmlDocument? More examples hereSonu Kapoor [MVP] Feel free to ask me any .NET question | Ajax Data Controls Forum Thanks, this is very helpful. What do I need to do extra to setup the schema for this xml file? Is the schema really necessary as well? Thx Mark You dont need to define any sc...

used a to converter and am now getting a syntax error.
ok I used a cool utility at to convert some to and it spit out a bunch of code which almost works but I am getting a syntax error on this line Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) I tried it that way and also like Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) but either way gave the same error Compiler Error Message: BC30035: Syntax error. Source Error: Line 26: Line ...

Converting classic to .NET 2 code, and .NET gets an error back from ADS?
 For future-proofing, our Internal Phone Directory is being moved onto our AD servers, and obviously we're using LDAP for queries.To get the phoneboook queries working, I adapted the current classic ASP code to use LDAP, and that works fine. However, we're wanting to move these pages to .NET, and that's where the problem comes in. Using the same basic logic from the Classic code (90% of its unchanged) to produce an LDAP query, I get the error  155 Unknown error (0x80005000)This is using the same website, and so the same credentials  - unless aspx pages run und...

Hoew to convert to/from Delphi 32 TDateTime and .NET Datetime
Hi If we have code that uses Tdatetime, and convert the code to .Net, what should we use: 1. as type Tdatetime replacement? 2. to marshal .Net datetime to TDateTime? Thanks very much -- E.P. Enrico Pergola wrote: > Hi > > If we have code that uses Tdatetime, and convert the code to .Net, what should we use: > 1. as type Tdatetime replacement? > 2. to marshal .Net datetime to TDateTime? > Thanks very much > You can start using the type TDateTime from ShineOn. But after you have a compiling and working code base, and after you created enough test cas...

Problem with Linq to XML in .net 3.5 project (previously converted from .net 2.0)
 Hi!I'm experiencing some problems with Linq to XML in .net 3.5 and I hope someone will be able to help me. I have the following code: 1 XDocument xml = XDocument.Load(FileUpload1.PostedFile.FileName);2 3 4 int no_of_rows = xml.Root.Descendants("{}tr").Count();5 6 int no_of_cells = xml.Root.Descendants("{}tc").Count();7 8 int no_of_columns = (no_of_cells/no_of_rows);9 ...

------_=_NextPart_001_01C6429F.D89AA417 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello, Net::LDAP Net::LDAPS Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, ....) password? I don't like to write the secret password to the perl file. Best regards Barbara Wilbert ------_=_NextPart_001_01C6429F.D89AA417-- Wilbert Barbara (CI/OSI) * wrote: > Hello, > > Net::LDAP > Net::LDAPS > > Is there a possible to LDAP bind with an encrypted (SHA, SSHA, CRYPT, > ......

VS.NET 2.0 Datagrid View issue. String was not recognized as a valid DateTime.
I am using the Datagridview(s) on a page. I have the First Datagridview bound to a drop down control of employee names. I link the Employee Id to the ObjectDataSource and look up detail info. - That is an integer, it works with no issues. On the first Data grid view  I have enabled select and bound a second Datagrid view (like a parent-child) to the selected value(s) of the first grid. My query for the Second Grid has 3 Parameters, one of which is a Date field. When I try to pass the parameters my application bombs. See the error below. I have tried everything but redefining my d...

Converting Sql DateTime to C# DateTime
Is there a quick and easy way to convert a DateTime value retrieved from a SQL 2005 query to a C# DateTime datatype?I can change my query to use sql's datepart function to return separate YYYY, MM and DD values and then use the right constructor to create a C# DateTime datatype but I'm just wondering if there's some C# method that will do the conversion for me. Thanks.  If the column in SQL is declared as a datetime then it is real easy to convert it to a .NET datetime object.e.g.lets assume you have a datarow which is a record retrieved from the database and the datetime ...

Web resources about - Issue when converting XML dateTime to .NET DateTime -

PastBook’s Integration Eases Process Of Converting Facebook Content To Books
PastBook , one of several companies that allow Facebook users to publish their content on the social network in actual books , announced the ...

Facebook No Longer Converting Groups Into Pages
Back when Facebook first launched Facebook Pages, many businesses and brands who had built up substantial audiences in their Facebook Groups ...

Zwartz Laminating-Converting B.V. on the App Store on iTunes
Get Zwartz Laminating-Converting B.V. on the App Store. See screenshots and ratings, and read customer reviews.

"Occupier" Thanked Former Soviet Citizen for "Converting" Him to Capitalism, Pro-Israel, Pro-USA - YouTube ...
May Day Demonstration on Union Square in New York City Zionism & Birth of Modern Israel in 1948: Former Soviet Citizen Pays Tribute to Ben-Gurion ...

Click go fears of converting print files
Is there a way to convert a print queue item to a .RTF or .PDF file? I like to save or email them. - The Sydney Morning Herald

Sudanese woman ordered to hang under sharia law for converting to Christianity gives birth
Khartoum, Sudan: A Christian Sudanese woman sentenced to hang for apostasy has given birth in jail, a Western diplomat said on Tuesday.

Imams warn against radicalism to Aboriginal inmates converting to Islam
The prison system has enlisted the help of ASIO to crack down on radicalisation behind bars amid revelations that Aboriginals are converting ...

Converting the world's companies one by one - The Science Show - ABC Radio National (Australian Broadcasting ...
Image: Trucks carrying logs make their way up a road in Jambi, Indonesia. A vast area of the Sumatran forest, and orangutan habitat, is being ...

Converting Churches Into Homes Is The Latest Hollywood Trend
You don't have to be a believer to be moved by the beauty of a church.

Resources last updated: 11/24/2015 4:02:19 PM