For those people in the U.S. who are concerned that this morning Punxsutawney Phil, the Seer of Seers, Prognosticator of Prognosticators, emerged, reluctantly, but alertly, and stated in groundhog-ese, “I definitely see a shadow”, let me allay your fears using Groovy:
[sourcecode language=”groovy”]
Calendar cal = Calendar.instance
cal.set(year:2014, month:Calendar.FEBRUARY, date:2)
def groundhogDay = cal.time
cal.set(year:2014, month:Calendar.MARCH, date:20)
def firstDayOfSpring = cal.time
int days = firstDayOfSpring – groundhogDay
println """There are $days days between Groundhog Day and the first Day of Spring.
That’s ${(int) (days/7)} weeks and ${days % 7} days.
"""
[/sourcecode]
The result of that script is:
There are 46 days between Groundhog Day and the first Day of Spring.
That's 6 weeks and 4 days.
In other words, “six more weeks of winter” is a good thing, because otherwise we’d have to wait an extra four days.
A few notes are in order:
- Here is the official Groundhog Day site.
- According to the Wikipedia page, Phil has been predicting the weather since 1887. His accuracy rate is only about 39%, however.
- Some kind of Groundhog Day celebration has been recorded since as far back as 1841. It bears similarities to the pagan festival of Imbolc, among others.
- If you don’t like using the
Calendar
class (and who does?), the Groovy JDK also adds aparse
method directly tojava.util.Date
:
[sourcecode language=”groovy”]
Date groundhogDay = Date.parse(‘MM/dd/yyyy’, ’02/02/2014′)
Date firstDayOfSpring = Date.parse(‘MM/dd/yyyy’, ’03/20/2014′)
[/sourcecode]
and the rest is the same. - The Vernal Equinox this year occurs on March 20, 2014, at 1:57pm EDT.
- I considered posting this blog entry over and over as some sort of weak tribute to the movie, but at least I spared you that. 🙂
There’s more, but I have to go get ready for our Super Bowl party, where the announcers have been talking about the weather all week and will no doubt be disappointed that the temperature will be in the 40s (Fahrenheit).
Leave a Reply