[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-janitors] #1014: posix: string->time preserves the year acc
From: |
Chicken Trac |
Subject: |
Re: [Chicken-janitors] #1014: posix: string->time preserves the year accross multiple invocations |
Date: |
Sat, 25 May 2013 01:11:14 -0000 |
#1014: posix: string->time preserves the year accross multiple invocations
-----------------------------+----------------------------------------------
Reporter: certainty | Owner:
Type: defect | Status: new
Priority: major | Milestone: someday
Component: core libraries | Version: 4.8.x
Resolution: | Keywords:
-----------------------------+----------------------------------------------
Comment(by zbigniew):
This is technically a misuse of strptime, as you shouldn't retrieve fields
you haven't set.
One option is to init the struct to the current date, which makes
everything relative to today. This is annoying to implement and not
always what you want.
Instead I suggest behaving like python: init the struct to 1900/01/01
00:00:00.
The problem is strptime behaves differently on different platforms: for
example on OS X, it won't update the weekday or day of year, whereas it
does on glibc.
So, the attached patch also uses mktime to ensure week/year day is set.
Note that this may, or may not, cause the time to be interpreted as local
time. On the other hand, parsing timezones with strptime is hit and miss
anyway -- on OS X the only legal timezones are the local TZ and "GMT"
(everything else bombs out).
mktime() is a bit of a question mark, I'd want to see testing on a few
platforms before applying it. It can be removed, with the caveat that
weekday will be wrong as mentioned above.
--
Ticket URL: <http://bugs.call-cc.org/ticket/1014#comment:2>
Chicken Scheme <http://www.call-with-current-continuation.org/>
Chicken Scheme is a compiler for the Scheme programming language.