@bart-krakowski/get-week-info-polyfill

中文文档
1.0.8发布于 2024/08/01TypeScriptES Module零依赖近 30 天下载 2635

This package provides a polyfill for the Intl.Locale API, adding the getWeekInfo method if it is not already available in the environment.

原始使用文档
文档目录4 节
  1. Installation
  2. Usage
  3. API
  4. Returns:

Intl.Locale.prototype.getWeekInfo() polyfill

This package provides a polyfill for the Intl.Locale API, adding the getWeekInfo method if it is not already available in the environment.

Installation

npm install @bart-krakowski/get-week-info-polyfill

Usage

require('@bart-krakowski/get-week-info-polyfill')

const he = new Intl.Locale('he') // Hebrew (Israel)
console.log(he.getWeekInfo()) // { firstDay: 7, weekend: [5, 6], minimalDays: 1 }

const af = new Intl.Locale('af') // Afrikaans (South Africa)
console.log(af.getWeekInfo()) // { firstDay: 7, weekend: [6, 7], minimalDays: 1 }

const enGB = new Intl.Locale('en-GB') // English (United Kingdom)
console.log(enGB.getWeekInfo()) // { firstDay: 1, weekend: [6, 7], minimalDays: 4 }

const arAF = new Intl.Locale('ar-AF') // Arabic (Afghanistan)
console.log(arAF.getWeekInfo()) // { firstDay: 6, weekend: [4, 5], minimalDays: 1 }

const dvMV = new Intl.Locale('dv-MV') // Divehi (Maldives)
console.log(dvMV.getWeekInfo()) // { firstDay: 5, weekend: [6, 7], minimalDays: 1 }

API

Intl.Locale.prototype.getWeekInfo returns an object containing week information for the locale.

Returns:

  • WeekInfo An object with the following properties:
    • firstDay (number) An integer between 1 (Monday) and 7 (Sunday) indicating the first day of the week for the locale. Commonly 1, 5, 6, or 7.
    • weekend (number[]) An array of integers between 1 and 7 indicating the weekend days for the locale. This is usually continuous because UTS 35 stores weekendStart and weekendEnd instead.
    • minimalDays (number) An integer between 1 and 7 (commonly 1 and 4) indicating the minimal days required in the first week of a month or year, for week-of-year or week-of-month calculations (e.g. The 20th week of the year). For example, in the ISO 8601 calendar, the first week of a year must have at least 4 days in this year, so if January 1 is a Friday, Saturday, or Sunday, it will be numbered as part of the last week of the previous year.

版本与发布记录

@bart-krakowski/get-week-info-polyfill 共发布 9 个版本,首次发布于 2024/07/04;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.8latest2024/08/012 年前
1.0.72024/07/292 年前
1.0.62024/07/212 年前
1.0.52024/07/192 年前
1.0.42024/07/042 年前
1.0.32024/07/042 年前

关于 @bart-krakowski/get-week-info-polyfill 的常见问题

@bart-krakowski/get-week-info-polyfill 是什么?

This package provides a polyfill for the Intl.Locale API, adding the getWeekInfo method if it is not already available in the environment.

如何安装 @bart-krakowski/get-week-info-polyfill?

在项目目录运行 npm install @bart-krakowski/get-week-info-polyfill,或使用 pnpm add / yarn add / bun add。

@bart-krakowski/get-week-info-polyfill 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bart-krakowski/get-week-info-polyfill 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@bart-krakowski/get-week-info-polyfill 可以商用吗?

@bart-krakowski/get-week-info-polyfill 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@bart-krakowski/get-week-info-polyfill 的下载量有多少?

根据 npm 官方下载统计,@bart-krakowski/get-week-info-polyfill 在 2026/10/08 – 2026/11/06 这 30 天内被下载 2,635 次,日均约 88 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bart-krakowski/get-week-info-polyfill 还在维护吗?

最新版本 1.0.8 发布于 2024/08/01(2 年前);至今共发布 9 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/07/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。