Re: [Toybox] Stat %Z - What are valid values?
On Tue, Jan 24, 2017 at 05:47:46PM -0600, Rob Landley wrote: > > > On 01/21/2017 06:25 PM, Rich Felker wrote: > > On Sat, Jan 21, 2017 at 03:18:28PM -0600, Rob Landley wrote: > >>> Or if it's signed, that's -1346458162 which would be... sometime in the > >>> 1930's? hmmm... "./date -D %s -d -1346458162" is failing under glibc, > >>> and failing _differently_ under musl. (Wheee.) > >>> > >>> /me goes down tangent rathole debugging why. > >> > >>> > >>> (Answer: musl doesn't implement %s at all, and glibc doesn't allow the > >>> %s value it converts to be negative.) > >> > >> Query: does bionic strptime() handle %s, and if so does it handle > >> negative input values? (If not I suppose I can try to special case this > >> in toybox, but ew.) > >> > >> Also, Rich: any interest in adding this to musl? > > > > strptime with %s? I suspect there are some nasty underspecified issues > > with how it interacts with timezones. > > I thought unix time was always UTS and the timezone just affected how it > was displayed? The problem is that strptime produces a struct tm. When the fields it's parsing to produce this struct tm are "broken down time" fields, strptime does not need to know/care whether the caller is going to interpret the struct tm as UTC or local time; it's just a bunch of numbers. But when strptime is going to take a unix time value (seconds since epoch) and convert it to struct tm, it matters whether the caller is supposed to treat that struct tm as UTC or local. Rich ___ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net
Re: [Toybox] Stat %Z - What are valid values?
On Tue, Jan 24, 2017 at 3:47 PM, Rob Landleywrote: > > > On 01/21/2017 06:25 PM, Rich Felker wrote: >> On Sat, Jan 21, 2017 at 03:18:28PM -0600, Rob Landley wrote: Or if it's signed, that's -1346458162 which would be... sometime in the 1930's? hmmm... "./date -D %s -d -1346458162" is failing under glibc, and failing _differently_ under musl. (Wheee.) /me goes down tangent rathole debugging why. >>> (Answer: musl doesn't implement %s at all, and glibc doesn't allow the %s value it converts to be negative.) >>> >>> Query: does bionic strptime() handle %s, and if so does it handle >>> negative input values? (If not I suppose I can try to special case this >>> in toybox, but ew.) >>> >>> Also, Rich: any interest in adding this to musl? >> >> strptime with %s? I suspect there are some nasty underspecified issues >> with how it interacts with timezones. > > I thought unix time was always UTS and the timezone just affected how it > was displayed? > >> All the standard specifiers work >> with broken-down (struct tm) time so timezone is irrelevant to how >> they operate. > > I'm tempted to add support for it myself, but the problem is the format > could be "time=[%s]" and I'd have to parse context data. (I can just > strstr() but I'd have to make sure it wasn't %%s...) > >> So the answer isn't no, but "it's complicated", and needs more >> research on how other implementations work, > > I think it's just glibc so far? i have an open feature request for %s in bionic (http://code.google.com/p/android/issues/detail?id=229155) and iirc freebsd and netbsd both have it, but different (gmtime versus localtime). openbsd didn't have it. ios matches freebsd. which meant ios and glibc disagree, which is why that's on my big list of things i'm not sure what to do about. glibc was probably there first, but ios is probably more relevant. i'd rather work on making the icu4c APIs available to apps anyway :-) >> if they're consistent, >> pros and cons of different possible behaviors, etc. > > It's not that big a deal for me to do it myself, I just thought I'd > raise the issue. If bionic and musl both add %s that supports negative > numbers, I'm happy to leave glibc as broken until they catch up. If they > don't, it makes sense to do it myself... > >> Rich > > Rob -- Elliott Hughes - http://who/enh - http://jessies.org/~enh/ Android native code/tools questions? Mail me/drop by/add me as a reviewer. ___ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net
Re: [Toybox] Stat %Z - What are valid values?
On 01/21/2017 06:25 PM, Rich Felker wrote: > On Sat, Jan 21, 2017 at 03:18:28PM -0600, Rob Landley wrote: >>> Or if it's signed, that's -1346458162 which would be... sometime in the >>> 1930's? hmmm... "./date -D %s -d -1346458162" is failing under glibc, >>> and failing _differently_ under musl. (Wheee.) >>> >>> /me goes down tangent rathole debugging why. >> >>> >>> (Answer: musl doesn't implement %s at all, and glibc doesn't allow the >>> %s value it converts to be negative.) >> >> Query: does bionic strptime() handle %s, and if so does it handle >> negative input values? (If not I suppose I can try to special case this >> in toybox, but ew.) >> >> Also, Rich: any interest in adding this to musl? > > strptime with %s? I suspect there are some nasty underspecified issues > with how it interacts with timezones. I thought unix time was always UTS and the timezone just affected how it was displayed? > All the standard specifiers work > with broken-down (struct tm) time so timezone is irrelevant to how > they operate. I'm tempted to add support for it myself, but the problem is the format could be "time=[%s]" and I'd have to parse context data. (I can just strstr() but I'd have to make sure it wasn't %%s...) > So the answer isn't no, but "it's complicated", and needs more > research on how other implementations work, I think it's just glibc so far? > if they're consistent, > pros and cons of different possible behaviors, etc. It's not that big a deal for me to do it myself, I just thought I'd raise the issue. If bionic and musl both add %s that supports negative numbers, I'm happy to leave glibc as broken until they catch up. If they don't, it makes sense to do it myself... > Rich Rob ___ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net