Skip to content

Commit

Permalink
Fix tests (#1336)
Browse files Browse the repository at this point in the history
* Fix tokenParse tests import broken by d6ea633

Co-authored-by: dobon <dobon@users.noreply.github.com>
  • Loading branch information
icambron and dobon authored Nov 29, 2022
1 parent d6ea633 commit 3858a2a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/parsing.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Not every token supported by `DateTime#toFormat` is supported in the parser. For

### Parsing Two Digit Years

In order to parse a year (or ISO week year) using the `yy` (or `kk`) tokens from a two digit string, a cutoff year after which a the year is interpreted as the current century must be used. By default, the cutoff date is 60, ie: the string "60" is parsed as the year 2060, and the string "61" is parsed as the year 1961. The cutoff year can be configured using `Settings.twoDigitCutoffYear`.
In order to parse a two digit string as a year (or ISO week year), the `yy` (and `kk`) token must use a cutoff year after which the year being parsed is interpreted as referring to the current century. By default, the cutoff year is set to 60, meaning that the string "60" is parsed as the year 2060, and the string "61" is parsed as the year 1961. The cutoff year can be configured using `Settings.twoDigitCutoffYear`.

### Debugging

Expand Down
3 changes: 2 additions & 1 deletion src/impl/regexParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
signedOffset,
parseInteger,
parseMillis,
ianaRegex,
isUndefined,
parseFloating,
} from "./util.js";
Expand All @@ -21,6 +20,8 @@ import IANAZone from "../zones/IANAZone.js";
* Some extractions are super dumb and simpleParse and fromStrings help DRY them.
*/

const ianaRegex = /[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;

function combineRegexes(...regexes) {
const full = regexes.reduce((f, r) => f + r.source, "");
return RegExp(`^${full}$`);
Expand Down
3 changes: 0 additions & 3 deletions src/impl/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,3 @@ export function formatOffset(offset, format) {
export function timeObject(obj) {
return pick(obj, ["hour", "minute", "second", "millisecond"]);
}

export const ianaRegex =
/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;
2 changes: 1 addition & 1 deletion test/datetime/tokenParse.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global test expect */
import { DateTime } from "../../src/luxon";
import Helpers from "../helpers";

import Settings from "../../src/settings";
import { ConflictingSpecificationError } from "../../src/errors";

//------
Expand Down

0 comments on commit 3858a2a

Please sign in to comment.