Pooh program example 04-time.p
# get current date / time; functions: localtime, gmtime, currenttime daysofweek = [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat' ] ctime = currenttime() println( ~msg 'The seconds passed since Jan 1 1970 UTC time [ ctime ] ' ) [ secs, mins, hour, dayofmonth, month, year, dayofweek, _ ] = localtime( ~epoch ctime ) println( ~msg 'UTC time: Today is [daysofweek[dayofweek+1]] the time is [hour]:[mins]:[secs] [dayofmonth]/[month]/[year]' ) [ secs, mins, hour, dayofmonth, month, year, dayofweek, _ ] = gmtime( ~epoch ctime ) println( ~msg 'UTC time: Today is [daysofweek[dayofweek+1]] the time is [hour]:[mins]:[secs] [dayofmonth]/[month]/[year]' )
The seconds passed since Jan 1 1970 UTC time 1361988269 UTC time: Today is Wed the time is 13:4:29 27/1/2013 UTC time: Today is Wed the time is 18:4:29 27/1/2013Trace output for 04-time.p
003|daysofweek = [ 'Sun' , 'Mon' , 'Tue' , 'Wed' , 'Thur' , 'Fri' , 'Sat'] 005|... = currenttime( )... 005|ctime = currenttime( ):1361988269 006|println( ~msg 'The seconds passed since Jan 1 1970 UTC time ' .. ctime:1361988269 .. ' ' )... 008|... = localtime( ~epoch ctime:1361988269 )... 008|[ secs:29 , mins:4 , hour:13 , dayofmonth:27 , month:1 , year:2013 , dayofweek:3 , ] = localtime( ~epoch ctime:1361988269 ):[ 29, 4, 13, 27, 1, 2013, 3, 57, 0 ] 010|println( ~msg 'UTC time: Today is ' .. daysofweek[(dayofweek:3 + 1):4]:'Wed' .. ' the time is ' .. hour:13 .. ':' .. mins:4 .. ':' .. secs:29 .. ' ' .. dayofmonth:27 .. '/' .. month:1 .. '/' .. year:2013 .. '' )... 011|... = gmtime( ~epoch ctime:1361988269 )... 011|[ secs:29 , mins:4 , hour:18 , dayofmonth:27 , month:1 , year:2013 , dayofweek:3 , ] = gmtime( ~epoch ctime:1361988269 ):[ 29, 4, 18, 27, 1, 2013, 3, 57, 0 ] 013|println( ~msg 'UTC time: Today is ' .. daysofweek[(dayofweek:3 + 1):4]:'Wed' .. ' the time is ' .. hour:18 .. ':' .. mins:4 .. ':' .. secs:29 .. ' ' .. dayofmonth:27 .. '/' .. month:1 .. '/' .. year:2013 .. '' )...