Day of the week: Difference between revisions
Content added Content deleted
(added ruby) |
|||
Line 296: | Line 296: | ||
25 Dec 2107 |
25 Dec 2107 |
||
25 Dec 2112 |
25 Dec 2112 |
||
25 Dec 2118 |
25 Dec 2118 |
||
</pre> |
|||
The Time class overflows at the Unix epoch in 2038: |
|||
<ruby>SUNDAY = 0 |
|||
for year in 2008..2121 |
|||
day = Time.local(year, 12, 25) |
|||
if day.wday == SUNDAY |
|||
puts '12 Dec %d' % year |
|||
end |
|||
end</ruby> |
|||
Output: |
|||
<pre>12 Dec 2011 |
|||
12 Dec 2016 |
|||
12 Dec 2022 |
|||
12 Dec 2033 |
|||
ArgumentError: time out of range |
|||
</pre> |
|||
=={{header|UNIX Shell}}== |
=={{header|UNIX Shell}}== |