File tree 3 files changed +30
-0
lines changed
3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ import {
13
13
addMinute ,
14
14
addSecond ,
15
15
addHour ,
16
+ dayStart ,
17
+ dayEnd ,
16
18
format ,
17
19
formatStr ,
18
20
sameDay ,
@@ -1252,3 +1254,19 @@ describe("nearestDay", () => {
1252
1254
)
1253
1255
} )
1254
1256
} )
1257
+
1258
+ describe ( "dayStart" , ( ) => {
1259
+ it ( "can become the start of the day" , ( ) => {
1260
+ expect ( dayStart ( "2023-02-22T12:00:00Z" ) . toISOString ( ) ) . toBe (
1261
+ "2023-02-22T05:00:00.000Z"
1262
+ )
1263
+ } )
1264
+ } )
1265
+
1266
+ describe ( "dayEnd" , ( ) => {
1267
+ it ( "can become the start of the day" , ( ) => {
1268
+ expect ( dayEnd ( "2023-02-22T12:00:00Z" ) . toISOString ( ) ) . toBe (
1269
+ "2023-02-23T04:59:59.999Z"
1270
+ )
1271
+ } )
1272
+ } )
Original file line number Diff line number Diff line change
1
+ import { date } from "./date"
2
+
3
+ /**
4
+ * Returns a Date object for end of the given day.
5
+ * @param inputDate - A string or Date object
6
+ */
7
+ export function dayEnd ( inputDate : DateInput ) : Date {
8
+ const d = date ( inputDate )
9
+ d . setHours ( 23 , 59 , 59 , 999 )
10
+ return d
11
+ }
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ export { ap } from "./ap"
8
8
export { applyOffset } from "./applyOffset"
9
9
export { date } from "./date"
10
10
export { dayOfYear } from "./dayOfYear"
11
+ export { dayEnd } from "./dayEnd"
11
12
export { dayStart } from "./dayStart"
12
13
export { format } from "./format"
13
14
export { formatStr } from "./formatStr"
You can’t perform that action at this time.
0 commit comments