Skip to content

Instantly share code, notes, and snippets.

@primitive-type
Created March 6, 2017 23:02
Show Gist options
  • Save primitive-type/96a240f4a3c0660023b58e398d6f9736 to your computer and use it in GitHub Desktop.
Save primitive-type/96a240f4a3c0660023b58e398d6f9736 to your computer and use it in GitHub Desktop.
Two Digit School Year (e.g., "17-18")
defmodule SchoolYear do
# "17-18"
def get_two_digit_school_year do
[DateTime.utc_now.year, DateTime.utc_now.year + 1] # calendar years
|> Enum.map(
(fn (calendar_year) -> Integer.digits(calendar_year)
|> Enum.slice(2, 2)
|> Enum.join end)
)
|> Enum.join("-")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment