[Toybox] date with timezone

Frank Liu gfrankliu at gmail.com
Wed May 26 09:17:05 PDT 2021


A bit background, the TZ string actually came from the "stat":

$ ./toybox stat main.c
  File: main.c
  Size: 7673 Blocks: 16 IO Blocks: 512 regular file
Device: fe02h/65026d Inode: 3286769 Links: 1 Device type: 0,0
Access: (0644/-rw-r--r--) Uid: (502/fliu) Gid: (502/fliu)
Access: 2021-05-26 09:11:55.588533347 -0700
Modify: 2021-05-15 15:20:22.181927884 -0700
Change: 2021-05-15 15:20:22.181927884 -0700
$ ./toybox date -d "2021-05-15 15:20:22.181927884 -0700" +%s
date: bad date 2021-05-15 15:20:22.181927884 -0700



On Wed, May 26, 2021 at 5:05 AM Rob Landley <rob at landley.net> wrote:

> On 5/26/21 6:52 AM, Rob Landley wrote:
> > Can I maybe just write to "extern long timezone" directly? (And always
> zero
> > "daylight"?) Posix sort of implies I can:
> >
> >   https://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html
>
> Nope, because:
>
> DESCRIPTION
>        The tzset() function initializes the tzname variable from the TZ
> envi‐
>        ronment  variable.   This function is automatically called by the
> other
>        time conversion functions that depend on the timezone.
>
> Which says if I modify the variables myself it'll just overwrite them
> every time
> it calls a function that would use them.
>
> I'm going to step away from the computer before I reimplement asctime() and
> strftime() from scratch in lib/lib.c. (Like the gnu date people apparently
> already did, meaning it can't possibly be the right thing to do.)
>
> Rob
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20210526/d9335e5b/attachment-0001.htm>


More information about the Toybox mailing list