Skip to content

How do I determine whether the current month is June according to the user's system time zone? #26

Answered by BurntSushi
teohhanhui asked this question in Q&A
Discussion options

You must be logged in to vote

Zoned::now().month() == 6 is exactly the correct answer to whether it is June, according to the user's system.

time is doing the same work. It's just farming it out to libc. libc in this case will probably open /etc/localtime and 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/localtime is linked to anyway). So Jiff isn't really doing any extra work here as far as I can tell. And the /etc/localtime inspection is cached.

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
3 replies
@teohhanhui
Comment options

@BurntSushi
Comment options

@teohhanhui
Comment options

Answer selected by BurntSushi
Comment options

You must be logged in to vote
1 reply
@BurntSushi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #25 on July 22, 2024 16:14.