by PascalW on 1/19/25, 4:10 PM with 96 comments
by chikere232 on 1/19/25, 7:18 PM
They needed to have a locale matching the language of the localised time string they wanted to parse, they needed to use strptime to parse the string, they needed to use timegm() to convert the result to seconds when seen as UTC. The man pages pretty much describe these things.
The interface or these things could certainly be nicer, but most of the things they bring up as issues aren't even relevant for the task they're trying to do. Why do they talk about daylight savings time being confusing when they're only trying to deal with UTC which doesn't have it?
by d_burfoot on 1/19/25, 8:38 PM
I've wasted so many dreary hours trying to figure out crappy time processing APIs and libraries. Never again!
by 1970-01-01 on 1/19/25, 7:05 PM
Surely we'll have everything patched up by then..
by account42 on 1/20/25, 2:35 PM
by jonstewart on 1/19/25, 8:39 PM
by zX41ZdbW on 1/19/25, 7:18 PM
ClickHouse has the "parseDateTimeBestEffort" function: https://clickhouse.com/docs/en/sql-reference/functions/type-... and here is its source code: https://github.com/ClickHouse/ClickHouse/blob/74d8551dadf735...
by p0w3n3d on 1/19/25, 8:46 PM
Explanation: you can learn heap sort or FFT or whatever algorithm there is and implement it. But writing your own calendar from scratch, that will do for example chron job on 3 am in the day of DST transition, that works in every TZ, is a work for many people and many months if not years...
by blindriver on 1/20/25, 3:59 AM
by havermeyer on 1/20/25, 4:39 AM
by rstuart4133 on 1/19/25, 9:34 PM
If you are happy for the time to perhaps be wrong around the hours timezone changes, this is an easy hack:
import time
def time_mktime_utc(_tuple):
result = time.mktime(_tuple[:-1] + (0,))
return result * 2 - time.mktime(time.gmtime(result))
If you are just using it for display this is usually fine as time zone changes are usually timed to happen when nobody is looking.by TZubiri on 1/20/25, 2:53 PM
[Missing scene]
" We are releasing Http1.1 specifications whereby expirations are passed as seconds to expire instead of dates as strings."
by richrichie on 1/19/25, 10:13 PM
Why such self flagellation?
by TZubiri on 1/20/25, 3:03 PM
by udidnmem on 1/19/25, 5:56 PM
by sylware on 1/19/25, 6:13 PM
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.