@internationalized/date
Advanced tools
Comparing version 3.0.0-nightly.3074 to 3.0.0-nightly.3077
@@ -114,2 +114,4 @@ export interface AnyCalendarDate { | ||
export function maxDate<A extends DateValue, B extends DateValue>(a: A, b: B): A | B; | ||
export function isWeekend(date: DateValue, locale: string): boolean; | ||
export function isWeekday(date: DateValue, locale: string): boolean; | ||
type Mutable<T> = { | ||
@@ -116,0 +118,0 @@ -readonly [P in keyof T]: T[P]; |
{ | ||
"name": "@internationalized/date", | ||
"version": "3.0.0-nightly.3074+df9eb3253", | ||
"version": "3.0.0-nightly.3077+7e8a7f696", | ||
"description": "Internationalized calendar and date manipulation utilities", | ||
@@ -25,3 +25,3 @@ "license": "Apache-2.0", | ||
}, | ||
"gitHead": "df9eb3253328c2aee23de4ff3d48c63b4d8222e8" | ||
"gitHead": "7e8a7f69685139b3574453b424a5ad4c8fa4e808" | ||
} |
@@ -218,1 +218,42 @@ /* | ||
} | ||
const WEEKEND_DATA = { | ||
AF: [4, 5], | ||
AE: [5, 6], | ||
BH: [5, 6], | ||
DZ: [5, 6], | ||
EG: [5, 6], | ||
IL: [5, 6], | ||
IQ: [5, 6], | ||
IR: [5, 5], | ||
JO: [5, 6], | ||
KW: [5, 6], | ||
LY: [5, 6], | ||
OM: [5, 6], | ||
QA: [5, 6], | ||
SA: [5, 6], | ||
SD: [5, 6], | ||
SY: [5, 6], | ||
YE: [5, 6] | ||
}; | ||
export function isWeekend(date: DateValue, locale: string) { | ||
let julian = date.calendar.toJulianDay(date); | ||
// If julian is negative, then julian % 7 will be negative, so we adjust | ||
// accordingly. Julian day 0 is Monday. | ||
let dayOfWeek = Math.ceil(julian + 1) % 7; | ||
if (dayOfWeek < 0) { | ||
dayOfWeek += 7; | ||
} | ||
let region = getRegion(locale); | ||
// Use Intl.Locale for this once weekInfo is supported. | ||
// https://github.com/tc39/proposal-intl-locale-info | ||
let [start, end] = WEEKEND_DATA[region] || [6, 0]; | ||
return dayOfWeek === start || dayOfWeek === end; | ||
} | ||
export function isWeekday(date: DateValue, locale: string) { | ||
return !isWeekend(date, locale); | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
718227
7365