This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
open Jest; | ||
|
||
open Js.Date; | ||
|
||
describe("getWeekYear", () => { | ||
open ExpectJs; | ||
|
||
test("returns the local week-numbering year of the given date", () => { | ||
let date = makeWithYMD(~year=2019., ~month=11., ~date=29., ()); | ||
|
||
date |> ReDate.getWeekYear |> expect |> toEqual(2020.); | ||
}); | ||
|
||
test("allows to specify which day is the first day of the week", () => { | ||
let date = makeWithYMD(~year=2019., ~month=11., ~date=23., ()); | ||
let getWeekYear' = ReDate.getWeekYear(~weekStartsOn=Monday); | ||
|
||
date |> getWeekYear' |> expect |> toEqual(2019.); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Week numbering helpers | ||
|
||
#### getWeekYear | ||
|
||
> Get the local week-numbering year of the given date. | ||
`let getWeekYear: (~weekStartsOn: day=?, Js.Date.t) => float` | ||
|
||
```reason | ||
let date = Js.Date.makeWithYMD(~year=2018., ~month=4., ~date=10., ()); | ||
date |> ReDate.getWeekYear; | ||
``` | ||
|
||
```reason | ||
let date = Js.Date.makeWithYMD(~year=2018., ~month=10., ~date=14., ()); | ||
let getWeekYear' = ReDate.getWeekYear(~weekStartsOn=Monday); | ||
date |> getWeekYear'; | ||
``` |
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
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