Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds month_name/1 function to Date module #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/calendar/date.ex
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,25 @@ defmodule Calendar.Date do
"""
def sunday?(date), do: day_of_week(date) == 7

@doc """
The name of the month as a string.
Takes a language code as the second argument. Defaults to :en for English.

## Examples

iex> {2015, 7, 6} |> month_name # July
"July"
iex> {2015, 2, 7} |> month_name # February
"February"
iex> {2015, 11, 5} |> month_name # November
"November"
"""
def month_name(date, lang \\ :en) do
date
|> contained_date
|> Calendar.Strftime.strftime!("%B", lang)
end

@doc """

## Examples
Expand Down