Time
Word | Action |
---|---|
NOW |
The current timestamp, milliseconds since 01 Jan 1970. |
FORMAT-TIME |
Takes a timestamp, timezone and "pattern". Returns a string which shows the time. The timezone is in minutes. |
YMDHM |
Takes five numbers which are year, month, day, hour and minute. Returns the timestamp given the values. |
YEAR, MONTH, DAY, HOUR, SECOND, DAY-OF-WEEK, JULIAN-DAY, WEEK |
Use these to extract the relevant portion of the timestamp. Note the answer will be in UTC. |
Examples
Example 1now hour . 2Example 2
now 480 "dd MMM yyyy HH:mm" format-time . 18 Jan 2017 10:02 okExample 3
2017 1 1 0 0 ymdhm . 1483228800000 ok
Quiz
Question 1
Write a word which takes a timezone in hours as an argument and returns current local timestamp.
: localTime ( timezoneHour -- timestamp ) \ sec min hr #hr 1000 60 * 60 * * now + ;
Question 2
What are the other "pattern" string that can be used in format-time?
MM,
MMM,
MMMM
yy
h:mm:ss a