How do I determine whether the current month is June according to the user's system time zone? #26
-
|
My use case is just checking the current "local" date / time, not going to store/send it in any way and/or perform any arithmetic on it. Specifically, the question in my case is: "Is it June now?" (as defined by the user's system) I have been unable to find anything that would let me do that without doing the unnecessary work of looking up the IANA timezone in the tzdb, but perhaps I'm just missing the obvious? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
|
|
Beta Was this translation helpful? Give feedback.
-
|
Thank you for the explanation and sorry for the noise. I realize this should have been a Q&A in the discussions instead. |
Beta Was this translation helpful? Give feedback.
Zoned::now().month() == 6is exactly the correct answer to whether it is June, according to the user's system.timeis doing the same work. It's just farming it out tolibc.libcin this case will probably open/etc/localtimeand use that file directly to determine the time zone transitions. Jiff will do something a little smarter and look for the tzid in the symlink of/etc/localtime, and then go look that time zone up in/usr/share/zoneinfo(which is where/etc/localtimeis linked to anyway). So Jiff isn't really doing any extra work here as far as I can tell. And the/etc/localtimeinspection is cached.