howto get the name of the season ?

  • Thread starter Thread starter Gillard
  • Start date Start date
G

Gillard

hello,
anyone have a snippet to get the name of the season for a date????

something like
GetSeason(today)

and it return summer
 
Why not just write a function...

Input the day / or the day# which is what you want.

<written in notepad >

Case day#
day# >= 1 and < 60 or day# >= 300 and <= 365
ReturningSeason = "Winter"
day# >= 61 and <= 90
ReturningSeason = "Spring"

....and so on

endcase

Im not sure if Austrialia is "Hot" in their "Winter" or if they actaully
have their seasons names reversed.
So when its summer here - its winter there (cold there - if you can call it
cold),
when its winter here - its summer there (hot there)

do they actaully call it a "Hot Winter" or a "Hot Summer" - that I do not
know.
 
Miro said:
Why not just write a function...

Input the day / or the day# which is what you want.

<written in notepad >

Case day#
day# >= 1 and < 60 or day# >= 300 and <= 365
ReturningSeason = "Winter"
day# >= 61 and <= 90
ReturningSeason = "Spring"

...and so on

endcase

Im not sure if Austrialia is "Hot" in their "Winter" or if they actaully
have their seasons names reversed.
So when its summer here - its winter there (cold there - if you can call
it cold),
when its winter here - its summer there (hot there)

do they actaully call it a "Hot Winter" or a "Hot Summer" - that I do
not know.

I can tell you that in Australia:
- Summer is Dec, Jan, Feb (it's hot)
- Autumn is Mar, Apr, May
- Winter is Jun, Jul, Aug (it's cold)
- Spring is Sep, Oct, Nov

Of course, in the tropics the season is really either wet or dry.

Sensibly, we avoid using equinoxes and/or solstices to determine the
seasons.

HTH
 
thank you for the idea
there is it but in french

Function saison(ByVal UneDate As String) As String
Dim num As Int32 = 0
Dim z As Date
Try
If Date.TryParse(UneDate, z) Then
num = z.DayOfYear
Select Case num
Case Is < 1
Return "error"
MsgBox(num)
Case Is < 81
If num > 0 Then
Return "hiver"
End If
Case Is < 173
If num > 80 Then
Return "printemps"
End If
Case Is < 265
If num > 172 Then
Return "été"
End If
Case Is < 356
If num > 264 Then
Return "automne"
End If
Case Is < 367
If num > 355 Then
Return "hiver"
End If
Case Else
Return "error"
End Select
Else
Return "error"
End If
Catch ex As Exception
Debug.Fail(ex.Message)
End Try

End Function
 
Gillard said:
hello,
anyone have a snippet to get the name of the season for a date????

something like GetSeason(today)

and it return summer

Do you want the meterological seasons, the astronomical seasons or the
temperature based seasons?
 
Thanks Jason,

I was in Australia years ago, and actually never 'thought' or 'checked' to
see if the 'names' of the seasons get 'moved'
I suspected they did, but I wasn't 100% sure.

Learn something new everyday.

Thanks.

Miro
 
Goran-
Do you want the meterological seasons, the astronomical seasons or the
temperature based seasons?
As my wife said when I asked: "When does a season start?

:-)

Cor
 
Gillard-

I think that you would in future start refactoring your code a little bit as
you are ready.
I did it in a way now for you (just by hand).

Module Module1

Sub Main()
Try
'To make it testable. The notation is in European non ISO
notation
Dim day = CDate(Now.ToString("dd-MM-yyyy"))
Dim num = day.DayOfYear
If num < New DateTime(day.Year, 3, 21).DayOfYear Then
Console.WriteLine("Hiver")
ElseIf num < New DateTime(day.Year, 6, 21).DayOfYear Then
Console.WriteLine("Printemps")
ElseIf num < New DateTime(day.Year, 9, 21).DayOfYear Then
Console.WriteLine("Eté")
ElseIf num < New DateTime(day.Year, 12, 21).DayOfYear Then
Console.WriteLine("Automne")
Else
Console.WriteLine("Hiver")
End If
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Console.ReadLine()

End Sub

End Module
///

-Cor
 
very nice thank you Cor

Cor Ligthert said:
Gillard-

I think that you would in future start refactoring your code a little bit
as you are ready.
I did it in a way now for you (just by hand).

Module Module1

Sub Main()
Try
'To make it testable. The notation is in European non ISO
notation
Dim day = CDate(Now.ToString("dd-MM-yyyy"))
Dim num = day.DayOfYear
If num < New DateTime(day.Year, 3, 21).DayOfYear Then
Console.WriteLine("Hiver")
ElseIf num < New DateTime(day.Year, 6, 21).DayOfYear Then
Console.WriteLine("Printemps")
ElseIf num < New DateTime(day.Year, 9, 21).DayOfYear Then
Console.WriteLine("Eté")
ElseIf num < New DateTime(day.Year, 12, 21).DayOfYear Then
Console.WriteLine("Automne")
Else
Console.WriteLine("Hiver")
End If
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Console.ReadLine()

End Sub

End Module
///

-Cor
 
Back
Top