Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two possible fixes ms Length varies, Timezone difference in string #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

B9Tony
Copy link

@B9Tony B9Tony commented Apr 12, 2016

#23

Using data obtained from a web service I found that the length of the number of milliseconds varied from 1 to 3 characters, this caused a out of bounds exception in CreateInteger() called by CreateDate which was assuming the millisecond length was 3. The fix I have in place only accounts for Z or no Z in the datetime string, it doesn't (yet) account for +-HH:MM listed in ISO 8601

Year:
YYYY (eg 1997)
Year and month:
YYYY-MM (eg 1997-07)
Complete date:
YYYY-MM-DD (eg 1997-07-16)
Complete date plus hours and minutes:
YYYY-MM-DDThh:mmTZD (eg 1997-07-16T19:20+01:00)
Complete date plus hours, minutes and seconds:
YYYY-MM-DDThh:mm:ssTZD (eg 1997-07-16T19:20:30+01:00)
Complete date plus hours, minutes, seconds and a decimal fraction of a
second
YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
where:

 YYYY = four-digit year
 MM   = two-digit month (01=January, etc.)
 DD   = two-digit day of month (01 through 31)
 hh   = two digits of hour (00 through 23) (am/pm NOT allowed)
 mm   = two digits of minute (00 through 59)
 ss   = two digits of second (00 through 59)
 s    = one or more digits representing a decimal fraction of a second
 TZD  = time zone designator (Z or +hh:mm or -hh:mm)

#11

When using dotnet 4 (or greater) using: DateTime.Parse(value, null, System.Globalization.DateTimeStyles.RoundtripKind); performs slightly faster and handles more situations than the previous code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant