Skip to content

Commit

Permalink
progress on all tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
kensnyder committed Oct 6, 2024
1 parent cf25770 commit 4695142
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/data/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const latn = {
MONTH2: '1[0-2]|0[1-9]',
DAY: '3[01]|[12]\\d|0?[1-9]',
DAY2: '3[01]|[12]\\d|0[1-9]',
OFFSET: '[±−+-][01]?\\d\\:?(?:[0-5]\\d)|GMT[±−+-]\\d{1,2}',
OFFSET: '(?:GMT)?[±−+-][01]?\\d?(?::?[0-5]\\d)?',
H24: '[01]\\d|2[0-3]',
H12: '0?[1-9]|1[012]',
MIN: '[0-5]\\d',
Expand Down
2 changes: 1 addition & 1 deletion src/formats/fuzzy/fuzzy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ const fuzzy = new Format({
);
workingString = workingString.trim();
}
if (workingString === '' /* || /\w/.test(workingString) === false*/) {
if (workingString === '') {
return extracted;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/formats/monthnameDayYear/monthnameDayYear.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ testDates({
name: 'monthname day year',
expected: { year: 2016, month: 3, day: 27 },
// ar and zh do not have a monthname
locales: localeList.filter(l => !/^ar|zh/.test(l)),
locales: localeList.filter(l => !/^ar|zh|cs|pt|sk/.test(l)),
formats: [
'cccc, MMMM dd yyyy',
'cccc MMMM dd yyyy',
Expand Down
19 changes: 19 additions & 0 deletions src/formats/timestamp/timestamp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Format from '../../Format/Format';

const timestamp = new Format({
/* prettier-ignore */
// $1 $2 $3 $4 $5 $6 $7 $8
template: "^(_YEAR4_)-(_MONTH_)-(_DAY_)[T ](_H24_):(_MIN_):(_SEC_)(:?\.(_MS_))?(:? ?(_OFFSET_|Z))?$",
units: [
'year',
'month',
'day',
'hour',
'minute',
'second',
'millisecond',
'offset',
],
});

export default timestamp;
30 changes: 16 additions & 14 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import monthnameDay from './formats/monthnameDay/monthnameDay';
import monthnameDayYear from './formats/monthnameDayYear/monthnameDayYear';
import time12Hours from './formats/time12Hours/time12Hours';
import time24Hours from './formats/time24Hours/time24Hours';
import timestamp from './formats/timestamp/timestamp';
import today from './formats/today/today';
import twitter from './formats/twitter/twitter';
import yearMonthDay from './formats/yearMonthDay/yearMonthDay';
Expand All @@ -30,26 +31,27 @@ const parser = new Parser();
parser
// all formats can have time strings at the end
.addFormats([
time24Hours,
time12Hours,
// from most unambiguous and popular to least
yearMonthDayWithDots,
yearMonthDay,
dayMonthnameYear,
monthnameDayYear,
timestamp,
// time24Hours,
// time12Hours,
// // from most unambiguous and popular to least
// yearMonthDayWithDots,
// yearMonthDay,
// dayMonthnameYear,
// monthnameDayYear,
monthDayYear,
dayMonthYear,
// dayMonthYear,
chinese,
korean,
twitter,
today,
ago,
monthnameDay,
dayMonthname,
monthDay,
dayMonth,
yearMonthnameDay,
yearMonthDayWithSlashes,
// monthnameDay,
// dayMonthname,
// monthDay,
// dayMonth,
// yearMonthnameDay,
// yearMonthDayWithSlashes,
atSeconds,
microsoftJson,
fuzzy,
Expand Down

0 comments on commit 4695142

Please sign in to comment.