VBA-tools / VBA-Web

VBA-Web: Connect VBA, Excel, Access, and Office for Windows and Mac to web services and the web
http://vba-tools.github.io/VBA-Web/
MIT License
2.01k stars 494 forks source link

ISO Date Parsing with offset (and no colon in offset) #421

Open joekane101 opened 4 years ago

joekane101 commented 4 years ago

Hello,

This bug #293 was for not calculating the offset. But here, the offset calculation fails if the offset is missing a colon.

So an iso date string of this form: "2018-01-26T07:06:51.000-0500"

actually parses to 02-15-2018 (I guess that the offset is being translated into '0500' hours offset in stead of 5 hours, zero minutes (05:00) because there is no colon in the input string to split the offset parts, here: utc_OffsetParts = VBA.Split(VBA.Right$(utc_Parts(1), Len(utc_Parts(1)) - utc_OffsetIndex), ":")

If I add the colon to the offset string, like this, it parses correctly "2018-01-26T07:06:51.000-05:00"

From this except, I assume that the input string offset format of "-0500" is valid, as would be "-05"

Time offsets from UTC The offset from UTC is appended to the time in the same way that 'Z' was above, in the form ±[hh]:[mm], ±[hh][mm], or ±[hh]. So if the time being described is one hour ahead of UTC, such as the time in Luanda, the zone designator would be "+01:00", "+0100", or simply "+01". To represent a time behind UTC the offset is negative. For example, the time in Quito is UTC−05:00 and the zone designator would then be "−05:00", "−0500", or simply "−05". For other time offsets see List of UTC time offsets. To represent a negative offset, ISO 8601 specifies using either a hyphen–minus or a minus sign character. If the interchange character set is limited and does not have a minus sign character, then the hyphen–minus should be used. ASCII does not have a minus sign, so its hyphen–minus character (code is 45 decimal or 2D hexadecimal) would be used. If the character set has a minus sign, then that character should be used. Unicode has a minus sign, and its character code is U+2212 (2212 hexadecimal); the HTML character entity invocation is −.

mohawk2 commented 4 years ago

If I get a "go" for https://github.com/VBA-tools/VBA-JSON/issues/169 I will fix this as part of it.