tags:

views:

373

answers:

7

Is there a way to, given a date, retrieve the season of the year? For any place on the globe?

Is this based on time zone as well as hemisphere?

Note that, In the southern hemisphere that summer is still during the warm months.

EDIT:

To clarify, I am talking about the astronomical seasons.

A: 

Personally, unless it was directly required, I would describe the different sections by the quarter rather than climate/period of the year.

monksy
It is for seasonal branding.
John Gietzen
Then whoever is doing the marketing/branding ought to tell you when you should switch from Summer to Fall. Expecting somehow that a computer can figure this out is but a small step towards having HAL rule the world.
Sinan Ünür
+2  A: 

I don't think this is standardized. Nor is this part of the well known globalization datasets.

Foxfire
I was looking for a globalized dataset. But, if there is none, I will just take what YOu have said and run with the US standard.
John Gietzen
+2  A: 

The answer depends on exactly how you want to define each season. This chart at Wikipedia shows the exact day and time changes slightly from year-to-year.

A simple solution that might be "good enough" is to use four fixed dates, say: 20-March, 21-June, 22-September, and 21-December.

Dan
A: 

Someone else can rattle off the code for you quickly but from the very Wikipedia.org article you referenced we have this:

The temperate areas

We can clearly distinguish six seasons. Dates listed here are for the Northern Hemisphere:[citation needed]

* Prevernal (1 March–1 May)
* Vernal (1 May–15 June)
* Estival (15 June–15 August)
* Serotinal (15 August–15 September)
* Autumnal (15 September–1 November)
* Hibernal (1 November–1 March)

You can then write a GetTemperateSeason() function to return the enumeration above based the month ranges.

rasx
A: 

northern/southern:

21/03 - start of spring/autumn

21/06 - start of summer/winter

23/09 - start of autumn/spring

22/12 - start of winter/summer

sometimes it IS delyed by one or two days, but for this you'll have to check in sites such as: timeanddate.com

Itay
There is no specific dates for the seasons, as they depend on the mean temperature.
Guffa
Actually the date shifts based on the solstice and equinox and not the temperature.
JamesEggers
A: 
public class Season
{
    private const string WINTER = "Winter";
    private const string SPRING = "Spring";
    private const string SUMMER = "Summer";
    private const string AUTUMN = "Autumn";

    public string Name { get; set; }
    public string Value { get; set; }

    public List<Season> LastFiveBillingQuarters
    {
        get
        {
            IList<Season> billingPeriods = new List<Season>();
            StringBuilder sbDisplayText;
            DateTime billingPeriod;

            for (int i = 0; i >= -12; i -= 3)
            {
                billingPeriod = DateTime.Now.AddMonths(i);
                var month = billingPeriod.Month;
                var day = billingPeriod.Day;
                var year = billingPeriod.Year;
                var ticks = billingPeriod.ToString();

                sbDisplayText = new StringBuilder();

                if ((month >= 12 || month < 03) & day >= 22)
                    sbDisplayText.Append(WINTER);
                else if (month >= 09 & day >= 23)
                    sbDisplayText.Append(AUTUMN);
                else if (month >= 06 & day >= 21)
                    sbDisplayText.Append(SUMMER);
                else if (month >= 03 & day >= 21)
                    sbDisplayText.Append(SPRING);

                sbDisplayText.Append(string.Format("{0}{1}", " ", year));

                billingPeriods.Add(new Season() { Name = sbDisplayText.ToString(), Value = ticks });
            }

            return billingPeriods.ToList();
        }
    }
}
Kevin Downey
This code is based on the assumption that location will always be in the northern hemisphere in 2010 which doesn't meet the global aspects of the question.
JamesEggers
+1  A: 
public class Season
{
    private const string WINTER = "Winter";
    private const string SPRING = "Spring";
    private const string SUMMER = "Summer";
    private const string AUTUMN = "Autumn";

    public string Name { get; set; }
    public string Value { get; set; }

    public List<Season> LastFiveBillingQuarters
    {
        get
        {
            IList<Season> billingPeriods = new List<Season>();
            StringBuilder sbDisplayText;
            DateTime billingPeriod;

            for (int i = 0; i >= -12; i -= 3)
            {
                billingPeriod = DateTime.Now.AddMonths(i);
                var month = billingPeriod.Month;
                var day = billingPeriod.Day;
                var year = billingPeriod.Year;
                var ticks = billingPeriod.ToString();

                sbDisplayText = new StringBuilder();

                if ((month >= 12 || month < 03) & day >= 22)
                    sbDisplayText.Append(WINTER);
                else if (month >= 09 & day >= 23)
                    sbDisplayText.Append(AUTUMN);
                else if (month >= 06 & day >= 21)
                    sbDisplayText.Append(SUMMER);
                else if (month >= 03 & day >= 21)
                    sbDisplayText.Append(SPRING);

                sbDisplayText.Append(string.Format("{0}{1}", " ", year));

                billingPeriods.Add(new Season() { Name = sbDisplayText.ToString(), Value = ticks });
            }

            return billingPeriods.ToList();
        }
    }
}
Kevin Downey