Day of the week: Difference between revisions
Content added Content deleted
m (#See_also) |
(UNIX Shell) |
||
Line 5: | Line 5: | ||
Using any standard date handling libraries of your programming language; compare the dates calculated with the output of other languages to discover any anomalies in the handling of dates which may be due to, for example, overflow in types used to represent dates/times similar to [[http://en.wikipedia.org/wiki/Y2k#See_also y2k]] problems. |
Using any standard date handling libraries of your programming language; compare the dates calculated with the output of other languages to discover any anomalies in the handling of dates which may be due to, for example, overflow in types used to represent dates/times similar to [[http://en.wikipedia.org/wiki/Y2k#See_also y2k]] problems. |
||
=={{header|UNIX Shell}}== |
|||
{{works with|bash}} |
|||
<pre>#! /bin/bash |
|||
for((i=2009; i <= 2099; i++)) |
|||
do |
|||
date -d "$i-12-25" |egrep Sun |
|||
done |
|||
exit 0 |
|||
</pre> |
|||
The first lines of output are |
|||
<pre> |
|||
Sun Dec 25 00:00:00 CET 2011 |
|||
Sun Dec 25 00:00:00 CET 2016 |
|||
Sun Dec 25 00:00:00 CET 2022 |
|||
Sun Dec 25 00:00:00 CET 2033 |
|||
date: invalid date `2038-12-25' |
|||
</pre> |
|||
I.e., starting from year 2038, the <tt>date</tt> command (which uses the glibc library, at least on GNU systems), is not able to recognise the date as a valid one! |