Skip to content

Commit

Permalink
to-timestamp: fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Garrison authored and Garrison committed Nov 2, 2023
1 parent 9c1e012 commit ed45eee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/to-timestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const toTimestamp = (value: string, deleteMS = false): number | null => {
result = new Date(Number(dateParts[2]), Number(dateParts[1]) - 1, Number(dateParts[0])).getTime();
} else if (value.includes('-')) {
const dateParts = value.split('-');
result = new Date(Number(dateParts[0]), Number(dateParts[1]) - 1, Number(dateParts[1])).getTime();
result = new Date(Number(dateParts[0]), Number(dateParts[1]) - 1, Number(dateParts[2])).getTime();
} else if (value.includes(':')) {
const timeParts = value.split(':');
const date = new Date();
Expand Down
4 changes: 2 additions & 2 deletions tests/to-timestamp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { toTimestamp } from '../src';
const TEST_TIME = '09:04';
const TEST_TIME_TS = 9 * 3600 * 1000 + 4 * 60 * 1000;
const TIMEZONE = new Date().getTimezoneOffset() * 60 * 1000;
const TEST_DATE_RU = '01.01.2000';
const TEST_DATE_US = '2000-01-01';
const TEST_DATE_RU = '15.11.2000';
const TEST_DATE_US = '2000-11-15';
const TEST_DATE_TS = new Date(`${TEST_DATE_US}`).getTime();

describe('toTimestamp', () => {
Expand Down

0 comments on commit ed45eee

Please sign in to comment.