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 src/DateFormat.elm
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ isLeapYear year_ =

quarter : Zone -> Posix -> Int
quarter zone posix =
monthNumber_ zone posix // 4
(monthNumber_ zone posix - 1) // 3



Expand Down
2 changes: 1 addition & 1 deletion tests/Fuzzers.elm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ datetime =
Fuzz.map Time.millisToPosix
(Fuzz.intRange
1529000000
1530000000
48699800000
)


Expand Down
29 changes: 29 additions & 0 deletions tests/Tests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,35 @@ suite =
, describe "quarterNumber"
[ fuzz Fuzzers.datetime "Is between 1 and 4" <|
withinRange 1 4 DateFormat.quarterNumber
, fuzz Fuzzers.datetime "Assigns months to appropriate quarters" <|
\date ->
let
quarterToMonths q =
case q of
"1" ->
[ "1", "2", "3" ]

"2" ->
[ "4", "5", "6" ]

"3" ->
[ "7", "8", "9" ]

"4" ->
[ "10", "11", "12" ]

_ ->
[]

quarter =
DateFormat.format [ DateFormat.quarterNumber ] utc date

month =
DateFormat.format [ DateFormat.monthNumber ] utc date
in
Expect.equal
True
(quarter |> quarterToMonths |> List.member month)
]
, describe "quarterSuffix"
[ fuzz Fuzzers.datetime "Is between 1 and 4" <|
Expand Down