<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: epoch code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 17 May 2008 17:47:32 GMT</pubDate>
    <description>DZone Snippets: epoch code</description>
    <item>
      <title>date-to-epoch conversion</title>
      <link>http://snippets.dzone.com/posts/show/1652</link>
      <description>&lt;code&gt;&lt;br /&gt;date-to-epoch: func [&lt;br /&gt;    "Returns a unix time (epoch) format from a date."&lt;br /&gt;    date [date!]&lt;br /&gt;    /local res&lt;br /&gt;][&lt;br /&gt;    ; If no time is given, negate our zone to give us 0:00 UTC&lt;br /&gt;	if none? date/time [date/time: negate now/zone]&lt;br /&gt;	; This uses the epoch base in UTC, so we assume that either&lt;br /&gt;	; the date is also in UTC, or has a zone offset included.&lt;br /&gt;	; DIFFERENCE fails for huge time differences, so we subtract&lt;br /&gt;	; them instead, giving us a difference in days, and multiply&lt;br /&gt;	; by the number of seconds in a day.&lt;br /&gt;	either res: attempt [to integer! difference date 1-Jan-1970/0:0:0] &lt;br /&gt;		[res] &lt;br /&gt;		[date - 1-Jan-1970/0:0:0 * 86400.0] &lt;br /&gt;]&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 08 Mar 2006 00:56:52 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1652</guid>
      <author>gregg.irwin (Gregg Irwin)</author>
    </item>
    <item>
      <title>epoch-to-date conversion</title>
      <link>http://snippets.dzone.com/posts/show/1651</link>
      <description>&lt;code&gt;&lt;br /&gt;epoch-to-date: func [&lt;br /&gt;    "Returns a date from unix time (epoch) format."&lt;br /&gt;    value [integer!] "Number of seconds since 1-Jan-1970"&lt;br /&gt;    /local date time&lt;br /&gt;][&lt;br /&gt;    value: to time! value&lt;br /&gt;    date: 1-Jan-1970 + round/down value / 24:0:0&lt;br /&gt;    time: value // 24:0:0&lt;br /&gt;    add now/zone to date! rejoin [date "/" time now/zone]&lt;br /&gt;]&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 08 Mar 2006 00:56:03 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1651</guid>
      <author>gregg.irwin (Gregg Irwin)</author>
    </item>
  </channel>
</rss>
