Live data from Hacker News

The surprising struggle to get a Unix Epoch time from a UTC string in C or C++

berthub.eu

1–10 of 106 posts

Re: The surprising struggle to get a Unix Epoch time from a UTC string in C or C++

#4
Until you understand that the core of unix time is the "day", in the end, you only need to know the first leap year (If I recall properly it is 1972), then you have to handle the "rules" of leap years, and you will be ok (wikipedia I think, don't use google anymore since they now force javascript upon new web engines).

I did write such code in RISC-V assembly (for a custom command line on linux to output the statx syscall output). Then, don't be scared, with a bit of motivation, you'll figure it out.

Re: The surprising struggle to get a Unix Epoch time from a UTC string in C or C++

#5
post #3
post #2

You cannot since it's missing time zone

UTC is a timezone, though. Or am I misunderstanding what you're saying?

That is fine as long as the input / output is always in UTC... but at the end of the day you often want to communicate that timepoint to a human user (e.g. an appointment time, the time at which some event happened, etc.), which is when our stupid monkey brains expect the ascii string you are showing us to actually make sense in our specific locale (including all of the warts each of those particular timezones have, including leap second, DST, etc.)

Re: The surprising struggle to get a Unix Epoch time from a UTC string in C or C++

#8
post #3

Earlier quoted context omitted.

UTC is a timezone, though. Or am I misunderstanding what you're saying?

UTC would be marked as +Z Without any marking, it could be anything

The article explicitly mentions UTC all over the place. It's UTC.
Post reply on HN