Skip to content

Instantly share code, notes, and snippets.

@karenpayneoregon
Created June 3, 2024 12:50
Show Gist options
  • Save karenpayneoregon/19006aae9ebb34ede08ed0415dab8192 to your computer and use it in GitHub Desktop.
Save karenpayneoregon/19006aae9ebb34ede08ed0415dab8192 to your computer and use it in GitHub Desktop.
Get season Northern hemisphere
public static class CommonHelpers
{
public static string GetSeason(int month) => $"The season is {month switch
{
1 or 2 or 12 => "winter",
> 2 and < 6 => "spring",
> 5 and < 9 => "summer",
> 8 and < 12 => "autumn",
_ => "unknown.",
}}.";
public static string CurrentSeason => GetSeason(DateTime.Now.Month);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment