Hi,
Can I use TryParse with dates in iso 8601 ? I cant seem to get the format string correct. How would I specify the T and the timezone at the end ?
Cheers,
John
Hi,
Can I use TryParse with dates in iso 8601 ? I cant seem to get the format string correct. How would I specify the T and the timezone at the end ?
Cheers,
John
Hi John, ISO 8601 is not fully supported at the moment, will be fixed and available in this weekly build.
Thanks.
Hi Diego,
I tried the latest from github,
Is this format string ok ?
var format := āyyyy-MM-ddTHH:mm:sszzzā;
with .net core calling DateTime ToString works ok but on Nougat
var someDate := new DateTime;
var value := someDate.ToString(format);
value is ā2020-1-30ā
Thanks,
John
??
Whats wrong with that ?
I guess I misunderstood your question, as the title mentioned DateTime.TryParse but the snipped just created a datetime without parsing.
The format string does look correct to me, but looking at the code, I see that ToString just gets passed do the platformās implementation, NSDateFormatter in the case of Cocoa, so Iād expect that to handle that properly. That said, aside from adding the 0 for the month, https://nsdateformatter.com shows the same output for your format string, just the date and not the timeā¦
It seems it s there āTā that shows it off, as this one works ok: āyyyy-MM-dd HH:mm:sszzz
ā
It needs to be able to handle the T, thatās iso 8601
I was testing the changes for tryparse. In my ios apps Iām using a cocoa static library for back and forth between dates and strings. I was testing tostring to see if I could replace that library with rtl2
I guess weād have/could write our own pure-Elements implementation ToString(format)
but that seems like a potentially bottomless task to cover fully. Iāll check what the team thinksā¦
Thanks. Isnāt that the opposite of DateParser ?
Iāve been exploring mapped types recently and its interesting to look at the rtl source code, to see how thatās implemented.
Yeah, you could say that.
At this stage, Iām almost tempted to convert DateTime from a mapped/container class into an entirely native implementation. If we have Parse and Format natively, thatās really the most tricky bitsā¦
I found this
https://developer.apple.com/documentation/foundation/nsiso8601dateformatter?language=objc
It appeared in ios10+
Looking at the RTL source, I would be happy if I had a ToISO8601String or somehow matched up the format and used that class instead of NSDateFormatter.
Iāll have to explore later on