mirror of
https://github.com/arthur-pbty/portfolio2023.git
synced 2026-06-06 14:20:42 +02:00
restart portfolio
This commit is contained in:
+39
-3
@@ -4,7 +4,7 @@ import Locale from "./impl/locale.js";
|
||||
import IANAZone from "./zones/IANAZone.js";
|
||||
import { normalizeZone } from "./impl/zoneUtil.js";
|
||||
|
||||
import { hasRelative } from "./impl/util.js";
|
||||
import { hasLocaleWeekInfo, hasRelative } from "./impl/util.js";
|
||||
|
||||
/**
|
||||
* The Info class contains static methods for retrieving general time and date related data. For example, it has methods for finding out if a time zone has a DST, for listing the months in any supported locale, and for discovering which of Luxon features are available in the current environment.
|
||||
@@ -48,6 +48,41 @@ export default class Info {
|
||||
return normalizeZone(input, Settings.defaultZone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the weekday on which the week starts according to the given locale.
|
||||
* @param {Object} opts - options
|
||||
* @param {string} [opts.locale] - the locale code
|
||||
* @param {string} [opts.locObj=null] - an existing locale object to use
|
||||
* @returns {number} the start of the week, 1 for Monday through 7 for Sunday
|
||||
*/
|
||||
static getStartOfWeek({ locale = null, locObj = null } = {}) {
|
||||
return (locObj || Locale.create(locale)).getStartOfWeek();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the minimum number of days necessary in a week before it is considered part of the next year according
|
||||
* to the given locale.
|
||||
* @param {Object} opts - options
|
||||
* @param {string} [opts.locale] - the locale code
|
||||
* @param {string} [opts.locObj=null] - an existing locale object to use
|
||||
* @returns {number}
|
||||
*/
|
||||
static getMinimumDaysInFirstWeek({ locale = null, locObj = null } = {}) {
|
||||
return (locObj || Locale.create(locale)).getMinDaysInFirstWeek();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the weekdays, which are considered the weekend according to the given locale
|
||||
* @param {Object} opts - options
|
||||
* @param {string} [opts.locale] - the locale code
|
||||
* @param {string} [opts.locObj=null] - an existing locale object to use
|
||||
* @returns {number[]} an array of weekdays, 1 for Monday through 7 for Sunday
|
||||
*/
|
||||
static getWeekendWeekdays({ locale = null, locObj = null } = {}) {
|
||||
// copy the array, because we cache it internally
|
||||
return (locObj || Locale.create(locale)).getWeekendDays().slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of standalone month names.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
|
||||
@@ -160,10 +195,11 @@ export default class Info {
|
||||
* Some features of Luxon are not available in all environments. For example, on older browsers, relative time formatting support is not available. Use this function to figure out if that's the case.
|
||||
* Keys:
|
||||
* * `relative`: whether this environment supports relative time formatting
|
||||
* @example Info.features() //=> { relative: false }
|
||||
* * `localeWeek`: whether this environment supports different weekdays for the start of the week based on the locale
|
||||
* @example Info.features() //=> { relative: false, localeWeek: true }
|
||||
* @return {Object}
|
||||
*/
|
||||
static features() {
|
||||
return { relative: hasRelative() };
|
||||
return { relative: hasRelative(), localeWeek: hasLocaleWeekInfo() };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user