1 The `timelocal()` function performs the inverse operation of `localtime()` 2 by taking a broken-down date and time dictionary and transforming it into 3 an epoch value according to the local system timezone. 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 timelocal(d1), 42 timelocal(d2), 43 timelocal(d3) 44 ]); 45 %} 46 -- End -- 47 48 -- Vars -- 49 TZ=CET-1CEST,M3.5.0/2,M10.5.0/3 50 -- End -- 51 52 -- Expect stdout -- 53 [ 54 1647953502, 55 1667989353, 56 946681200 57 ] 58 -- End --
This page was automatically generated by LXR 0.3.1. • OpenWrt