I am stuck with Date assertion in different timezo...
# codereview
g
I am stuck with Date assertion in different timezones. May someone give me a hint? https://gist.github.com/gonaumov/cc60cc8fafc74da937f8291a6efeda70
I tried to calculate the offset and managed to do it but I didn't find working solutions to detect daylight saving time switching.
k
hi, honestly I am not sure what you are trying to do, but I would try to convert dates to timestamps and compare them. not sure what is your source of data, because
2019-08-23 15:50:00
is not exact timestamp without timezone, so if you change timezone you change timestamp
👍 1
g
This was my trying to fix it. Sorry for gists but I don't have Slack on the PC: https://gist.github.com/gonaumov/6c9816cc251c2fec73234b585e2986b8 Probably the question is a but stupid but how to add a time zone to the string in way parser to understand it?
k
where does never.created come from? whats in it? that datetime in string should be in which time zone? how did you created formatter? did you set timezone to formatter?
👍 1
Copy code
"yyyy-MM-dd'T'HH:mm:ss.SSSZ" 	2001-07-04T12:08:56.235-0700
"yyyy-MM-dd'T'HH:mm:ss.SSSXXX" 	2001-07-04T12:08:56.235-07:00
👍 1
c
Or use
"yyyy-MM-dd'T'HH:mm:ssZ"
as the formatter and append
Z
to the time that has no timezone then the result will be a UTC time.
👍 1
m
just convert both dates to the same timezone and compare them?
👍 1
idk what is the problem
👍 1
g
Would you give me an example? :)
m
give me a test that will fail and should pass. maybe that's better to understand the point
119 Views