Created
March 6, 2017 23:02
-
-
Save primitive-type/96a240f4a3c0660023b58e398d6f9736 to your computer and use it in GitHub Desktop.
Two Digit School Year (e.g., "17-18")
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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