Skip to content

Commit

Permalink
Rename and export from index
Browse files Browse the repository at this point in the history
  • Loading branch information
ritave committed Oct 15, 2024
1 parent 3258293 commit e1bdde6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export * from './promise';
export * from './time';
export * from './transaction-types';
export * from './versions';
export * from './iso8601-date';
8 changes: 4 additions & 4 deletions src/iso8601-date.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TZDate } from '@date-fns/tz';
import assert from 'assert';

import { InvalidIso8601Date, parseDateTime } from './iso8601-date';
import { InvalidIso8601Date, parseIso8601DateTime } from './iso8601-date';

describe('parseDateTime', () => {
it.each([
Expand All @@ -19,7 +19,7 @@ describe('parseDateTime', () => {
['20300606T0603', new Date(2030, 5, 6, 6, 3)],
['20310707T070402', new Date(2031, 6, 7, 7, 4, 2)],
])('parses %s local-time correctly', (testIso, expectedDate) => {
const result = parseDateTime(testIso);
const result = parseIso8601DateTime(testIso);

expect(result).toBeInstanceOf(Date);
expect(result.toISOString()).toStrictEqual(expectedDate.toISOString());
Expand All @@ -44,7 +44,7 @@ describe('parseDateTime', () => {
['2023-04-04T04:04:04-01:01', new TZDate(2023, 3, 4, 4, 4, 4, '-01:01')],
['2023-04-04T04:04:04+02:02', new TZDate(2023, 3, 4, 4, 4, 4, '+02:02')],
])('parses %s with time-zone correctly', (testIso, expectedDate) => {
const result = parseDateTime(testIso);
const result = parseIso8601DateTime(testIso);

assert(result instanceof TZDate);
expect(result.timeZone).toStrictEqual(expectedDate.timeZone);
Expand Down Expand Up @@ -92,6 +92,6 @@ describe('parseDateTime', () => {
'2020-01-01T23:59:59-11:60',
'2020-01-01T23:59:59a',
])('throws on invalid date time "%s"', (testIso) => {
expect(() => parseDateTime(testIso)).toThrow(InvalidIso8601Date);
expect(() => parseIso8601DateTime(testIso)).toThrow(InvalidIso8601Date);
});
});
2 changes: 1 addition & 1 deletion src/iso8601-date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const InvalidIso8601Date = new Error('Invalid ISO-8601 date');
* @param value - An ISO-8601 formatted string.
* @returns A date if value is in local-time, a TZDate if timezone data provided.
*/
export function parseDateTime(value: string): Date | TZDate {
export function parseIso8601DateTime(value: string): Date | TZDate {
let at = 0;
let hasSeparators: boolean | null = null;
let state: ParseDateState = ParseDateState.YEAR;
Expand Down

0 comments on commit e1bdde6

Please sign in to comment.