Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "justinmimbs/date",
"summary": "Work with dates without times or zones",
"license": "BSD-3-Clause",
"version": "3.2.1",
"version": "3.3.0",
"exposed-modules": [
"Date"
],
Expand Down
20 changes: 17 additions & 3 deletions src/Date.elm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Date exposing
, Interval(..), ceiling, floor
, range
, compare, isBetween, min, max, clamp
, monthToNumber, numberToMonth, weekdayToNumber, numberToWeekday
, monthToNumber, numberToMonth, daysInMonth, weekdayToNumber, numberToWeekday, isLeapYear
)

{-|
Expand Down Expand Up @@ -65,9 +65,9 @@ module Date exposing
@docs compare, isBetween, min, max, clamp


# Month and Weekday helpers
# Month, Year, and Weekday helpers

@docs monthToNumber, numberToMonth, weekdayToNumber, numberToWeekday
@docs monthToNumber, numberToMonth, daysInMonth, weekdayToNumber, numberToWeekday, isLeapYear

-}

Expand Down Expand Up @@ -153,6 +153,13 @@ toRataDie (RD rd) =
-- CALCULATIONS


{-| See if a given year has 366 days (29th of Februrary).

isLeapYear 2019 == False

isLeapYear 2020 == True

-}
isLeapYear : Int -> Bool
isLeapYear y =
modBy 4 y == 0 && modBy 100 y /= 0 || modBy 400 y == 0
Expand Down Expand Up @@ -1466,6 +1473,13 @@ clamp ((RD a) as dateA) ((RD b) as dateB) ((RD x) as dateX) =
-- NUMBERS OF DAYS


{-| Return the number of days in the month, accounting for leap years.

daysInMonth 2019 Feb == 28

daysInMonth 2020 Feb == 29

-}
daysInMonth : Int -> Month -> Int
daysInMonth y m =
case m of
Expand Down