Skip to content

Commit 3ddc85b

Browse files
feat: adds dayStart, dayEnd to tests
1 parent 0275358 commit 3ddc85b

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

Diff for: src/__tests__/tempo.spec.ts

+18
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
addMinute,
1414
addSecond,
1515
addHour,
16+
dayStart,
17+
dayEnd,
1618
format,
1719
formatStr,
1820
sameDay,
@@ -1252,3 +1254,19 @@ describe("nearestDay", () => {
12521254
)
12531255
})
12541256
})
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+
})

Diff for: src/dayEnd.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
}

Diff for: src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export { ap } from "./ap"
88
export { applyOffset } from "./applyOffset"
99
export { date } from "./date"
1010
export { dayOfYear } from "./dayOfYear"
11+
export { dayEnd } from "./dayEnd"
1112
export { dayStart } from "./dayStart"
1213
export { format } from "./format"
1314
export { formatStr } from "./formatStr"

0 commit comments

Comments
 (0)