1 The `timegm()` function performs the inverse operation of `gmtime()` 2 by taking a broken-down date and time dictionary and transforming it into 3 an epoch value, assuming UTC time. 4 5 -- Testcase -- 6 {% 7 // check expected epoch 8 let d1 = { 9 "sec": 42, 10 "min": 51, 11 "hour": 13, 12 "mday": 22, 13 "mon": 3, 14 "year": 2022, 15 "wday": 2, 16 "yday": 81, 17 "isdst": 0 18 }; 19 20 // check that out of range values are normalized 21 let d2 = { 22 "sec": 33, 23 "min": 22, 24 "hour": 11, 25 "mday": 40, 26 "mon": 10, 27 "year": 2022, 28 "wday": 2, 29 "yday": 81, 30 "isdst": 0 31 }; 32 33 // check that everything except mday, mon, year is optional 34 let d3 = { 35 "mday": 1, 36 "mon": 1, 37 "year": 2000 38 }; 39 40 printf("%.J\n", [ 41 timegm(d1), 42 timegm(d2), 43 timegm(d3) 44 ]); 45 %} 46 -- End -- 47 48 -- Expect stdout -- 49 [ 50 1647957102, 51 1667992953, 52 946684800 53 ] 54 -- End --
This page was automatically generated by LXR 0.3.1. • OpenWrt