• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/tests/custom/03_stdlib/51_localtime

  1 The `localtime()` function returns the given epoch timestamp (or now,
  2 if omitted) as a dictionary containing broken-down date and time
  3 information according to the local system timezone.
  4 
  5 -- Testcase --
  6 {%
  7         let t = time();
  8         let d1 = localtime();
  9         let d2 = localtime(1647953502);
 10 
 11         // assert that localtime without epoch returns the current time
 12         let c = timelocal(d1);
 13         assert(c >= t && c <= t + 5, "localtime() result does not match time()");
 14 
 15         // dump fixed time and check expected output
 16         printf("%.J\n", d2);
 17 %}
 18 -- End --
 19 
 20 -- Vars --
 21 TZ=CET-1CEST,M3.5.0/2,M10.5.0/3
 22 -- End --
 23 
 24 -- Expect stdout --
 25 {
 26         "sec": 42,
 27         "min": 51,
 28         "hour": 13,
 29         "mday": 22,
 30         "mon": 3,
 31         "year": 2022,
 32         "wday": 2,
 33         "yday": 81,
 34         "isdst": 0
 35 }
 36 -- End --

This page was automatically generated by LXR 0.3.1.  •  OpenWrt