date-to-epoch: func [ "Returns a unix time (epoch) format from a date." date [date!] /local res ][ ; If no time is given, negate our zone to give us 0:00 UTC if none? date/time [date/time: negate now/zone] ; This uses the epoch base in UTC, so we assume that either ; the date is also in UTC, or has a zone offset included. ; DIFFERENCE fails for huge time differences, so we subtract ; them instead, giving us a difference in days, and multiply ; by the number of seconds in a day. either res: attempt [to integer! difference date 1-Jan-1970/0:0:0] [res] [date - 1-Jan-1970/0:0:0 * 86400.0] ]
You need to create an account or log in to post comments to this site.