I was under the impression the DateInRegion.day will return the day of the date in a certain region. However, when I tried it, it always returned the day in UTC, similar to Date.day. I have a need to get the current local day in my unit test. In my test, I need to compare the current date to the date of the end of the day (approx. 23:59). Here's the code:
This test works only 17 hours of the day. Because I am at UTC+7 TimeZone, It always fails at 17.00 UTC - 24.00 UTC because the dateTomorrow.day always returns today's day component.
Is this by design? If it is, it seems useless and can deceive the developers (like what I experienced myself). Is there another way for me to get the day component in a certain region?
I was under the impression the
DateInRegion.day
will return the day of the date in a certain region. However, when I tried it, it always returned the day in UTC, similar toDate.day
. I have a need to get the current local day in my unit test. In my test, I need to compare the current date to the date of the end of the day (approx. 23:59). Here's the code:This test works only 17 hours of the day. Because I am at UTC+7 TimeZone, It always fails at 17.00 UTC - 24.00 UTC because the
dateTomorrow.day
always returns today's day component.Is this by design? If it is, it seems useless and can deceive the developers (like what I experienced myself). Is there another way for me to get the day component in a certain region?
Thanks.