Five weekends: Difference between revisions

Content added Content deleted
m (→‎{{header|Phix}}: use a more explicit test for "Friday")
(Updated to work with version 1.4 of Nim.)
Line 4,583: Line 4,583:


const LongMonths = {mJan, mMar, mMay, mJul, mAug, mOct, mDec}
const LongMonths = {mJan, mMar, mMay, mJul, mAug, mOct, mDec}

var timeinfo = getLocalTime getTime()
timeinfo.monthday = 1


var sumNone = 0
var sumNone = 0
Line 4,591: Line 4,588:
var none = true
var none = true
for month in LongMonths:
for month in LongMonths:
if initDateTime(1, month, year, 0, 0, 0).weekday == dFri:
timeinfo.year = year
timeinfo.month = month
echo month, " ", year
if getLocalTime(timeInfoToTime timeinfo).weekday == dFri:
echo month," ",year
none = false
none = false
if none: inc sumNone
if none: inc sumNone

echo "Years without a 5 weekend month: ",sumNone</lang>
echo "\nYears without a 5 weekend month: ", sumNone</lang>
{{out}}
{{out}}
<pre>March 1901
<pre>March 1901
Line 4,611: Line 4,607:
January 2100
January 2100
October 2100
October 2100

Years without a 5 weekend month: 29</pre>
Years without a 5 weekend month: 29</pre>