Skip to content

Commit

Permalink
refactor: remove unused defaultOK parameter (#1435)
Browse files Browse the repository at this point in the history
`listingMode` function was being passed `defaultOK`, but this function doesn't accept any arguments since 22/12/2021 (c96b813).
  • Loading branch information
MonstraG authored Aug 9, 2023
1 parent 6e91308 commit 8eb9207
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
19 changes: 9 additions & 10 deletions src/impl/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ function mapWeekdays(f) {
return ms;
}

function listStuff(loc, length, defaultOK, englishFn, intlFn) {
const mode = loc.listingMode(defaultOK);
function listStuff(loc, length, englishFn, intlFn) {
const mode = loc.listingMode();

if (mode === "error") {
return null;
Expand Down Expand Up @@ -388,8 +388,8 @@ export default class Locale {
return this.clone({ ...alts, defaultToEN: false });
}

months(length, format = false, defaultOK = true) {
return listStuff(this, length, defaultOK, English.months, () => {
months(length, format = false) {
return listStuff(this, length, English.months, () => {
const intl = format ? { month: length, day: "numeric" } : { month: length },
formatStr = format ? "format" : "standalone";
if (!this.monthsCache[formatStr][length]) {
Expand All @@ -399,8 +399,8 @@ export default class Locale {
});
}

weekdays(length, format = false, defaultOK = true) {
return listStuff(this, length, defaultOK, English.weekdays, () => {
weekdays(length, format = false) {
return listStuff(this, length, English.weekdays, () => {
const intl = format
? { weekday: length, year: "numeric", month: "long", day: "numeric" }
: { weekday: length },
Expand All @@ -414,11 +414,10 @@ export default class Locale {
});
}

meridiems(defaultOK = true) {
meridiems() {
return listStuff(
this,
undefined,
defaultOK,
() => English.meridiems,
() => {
// In theory there could be aribitrary day periods. We're gonna assume there are exactly two
Expand All @@ -435,8 +434,8 @@ export default class Locale {
);
}

eras(length, defaultOK = true) {
return listStuff(this, length, defaultOK, English.eras, () => {
eras(length) {
return listStuff(this, length, English.eras, () => {
const intl = { era: length };

// This is problematic. Different calendars are going to define eras totally differently. What I need is the minimum set of dates
Expand Down
24 changes: 14 additions & 10 deletions src/impl/tokenParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ function escapeToken(value) {
return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
}

/**
* @param token
* @param {Locale} loc
*/
function unitForToken(token, loc) {
const one = digitRegex(loc),
two = digitRegex(loc, "{2}"),
Expand All @@ -73,9 +77,9 @@ function unitForToken(token, loc) {
switch (t.val) {
// era
case "G":
return oneOf(loc.eras("short", false), 0);
return oneOf(loc.eras("short"), 0);
case "GG":
return oneOf(loc.eras("long", false), 0);
return oneOf(loc.eras("long"), 0);
// years
case "y":
return intUnit(oneToSix);
Expand All @@ -93,17 +97,17 @@ function unitForToken(token, loc) {
case "MM":
return intUnit(two);
case "MMM":
return oneOf(loc.months("short", true, false), 1);
return oneOf(loc.months("short", true), 1);
case "MMMM":
return oneOf(loc.months("long", true, false), 1);
return oneOf(loc.months("long", true), 1);
case "L":
return intUnit(oneOrTwo);
case "LL":
return intUnit(two);
case "LLL":
return oneOf(loc.months("short", false, false), 1);
return oneOf(loc.months("short", false), 1);
case "LLLL":
return oneOf(loc.months("long", false, false), 1);
return oneOf(loc.months("long", false), 1);
// dates
case "d":
return intUnit(oneOrTwo);
Expand Down Expand Up @@ -163,13 +167,13 @@ function unitForToken(token, loc) {
case "c":
return intUnit(one);
case "EEE":
return oneOf(loc.weekdays("short", false, false), 1);
return oneOf(loc.weekdays("short", false), 1);
case "EEEE":
return oneOf(loc.weekdays("long", false, false), 1);
return oneOf(loc.weekdays("long", false), 1);
case "ccc":
return oneOf(loc.weekdays("short", true, false), 1);
return oneOf(loc.weekdays("short", true), 1);
case "cccc":
return oneOf(loc.weekdays("long", true, false), 1);
return oneOf(loc.weekdays("long", true), 1);
// offset/zone
case "Z":
case "ZZ":
Expand Down

0 comments on commit 8eb9207

Please sign in to comment.