Skip to content

Commit

Permalink
add nowISO8601 function implementation (#69)
Browse files Browse the repository at this point in the history
Co-authored-by: Dzmitry Yeliseyeu <[email protected]>
  • Loading branch information
dyeliseyev and Dzmitry Yeliseyeu authored Aug 29, 2024
1 parent 29b8962 commit b553551
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ describe("time utilities", () => {
expect(util.time.nowFormatted('YYYY-MM-dd HH:mm:ss')).toEqual("2021-02-01T00:00:00.000Z");
spied.mockRestore();
});
test("nowISO8601", async () => {
// patch date utilities to ensure consistency
const newDate = new Date(Date.UTC(2021, 1, 1));
const spied = jest.spyOn(global, 'Date').mockImplementation(() => newDate);

expect(util.time.nowISO8601()).toEqual("2021-02-01T00:00:00.000Z");
spied.mockRestore();
});
});

describe("dynamodb helpers", () => {
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ export const util = {
// TODO: not completely correct, but close enough probably
return new Date().toISOString();
},
nowISO8601: function() {
return new Date().toISOString();
},
},
transform: {
toDynamoDBFilterExpression: function(value) {
Expand Down

0 comments on commit b553551

Please sign in to comment.