Skip to content

Commit

Permalink
Add docstrings for days of the week (#31574)
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt authored and fredrikekre committed May 23, 2019
1 parent 5f808c6 commit c532cf2
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion stdlib/Dates/src/query.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,29 @@ dayofweek(dt::TimeType) = dayofweek(days(dt))

const Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday = 1, 2, 3, 4, 5, 6, 7
const Mon, Tue, Wed, Thu, Fri, Sat, Sun = 1, 2, 3, 4, 5, 6, 7

for (ii, day_ind, short_day, long_day) in ((1, "first", :Mon, :Monday), (2, "second", :Tue, :Tuesday), (3, "third", :Wed, :Wednesday), (4, "fourth", :Thu, :Thursday), (5, "fifth", :Fri, :Friday), (6, "sixth", :Sat, :Saturday), (7, "seventh", :Sun, :Sunday))
short_name = string(short_day)
long_name = string(long_day)
name_ind = day_ind
ind_str = string(ii)
@eval begin
@doc """
$($long_name)
$($short_name)
The $($name_ind) day of the week.
# Examples
```jldoctest
julia> $($long_name)
$($ind_str)
julia> $($short_name)
$($ind_str)
```
""" ($long_day, $short_day)
end
end
dayname(day::Integer, locale::DateLocale) = locale.days_of_week[day]
dayabbr(day::Integer, locale::DateLocale) = locale.days_of_week_abbr[day]
dayname(day::Integer; locale::AbstractString="english") = dayname(day, LOCALES[locale])
Expand Down

0 comments on commit c532cf2

Please sign in to comment.