@equinor/fusion-wc-date

中文文档
1.2.5发布于 2026/10/22ISCTypeScriptCommonJS构建来源已验证近 30 天下载 1971
## `fusion-wc-date` [![Published on npm](https://img.shields.io/npm/v/@equinor/fusion-wc-date.svg)](https://www.npmjs.com/package/@equinor/fusion-wc-date)
原始使用文档
文档目录9 节
  1. fusion-wc-date
  2. Installation
  3. DateTime <fwc-datetime>
  4. Example Usage
  5. Properties/Attributes
  6. Range <fwc-daterange>
  7. Example Usage
  8. Slots
  9. Properties/Attributes

fusion-wc-date Published on npm

Storybook

Installation

npm install @equinor/fusion-wc-date

DateTime <fwc-datetime>

Example Usage

Date

return (
  <fwc-datetime format={DateTimeFormat.date} date='2021-08-09T11:12:49Z' />
);

Date & Time

return (
  <fwc-datetime format={DateTimeFormat.datetime} date='2021-08-09T11:12:49Z' />
);

Time

return (
  <fwc-datetime format={DateTimeFormat.time} date='2021-08-09T11:12:49Z' />
);

Custom

return (
  <fwc-datetime format='yyyy.MM.dd' date='2021-08-09T11:12:49Z' />
);

Alternative format type

The format variable can also be given as a value instead of a typed enum

return (
  <fwc-datetime format='datetime' date='2021-08-09T11:12:49Z' />
);

With custom locale property

return (
  <fwc-datetime format={DateTimeFormat.time} date='2021-08-09T11:12:49Z' locale='nb' />
);

Properties/Attributes

NameTypeDefaultDescription
datestringcurrent dateThe date to format in ISO format. See 'ISO_8601'.
formatDateTimeFormat* or stringdatetimePredefined or custom format to use. Based on Unicode Technical Standard #35.
localeLocaleName**enGBUsed to override the locale for which the date format is based. See date-fns Locale.

* DateTimeFormat is exported by fwc-date.

enum DateTimeFormat {
  date='dd.MM.yyyy',
  time='HH:mm',
  datetime='HH:mm dd.MM.yyyy',
  time_with_seconds='HH:mm:ss',
  datetime_with_seconds='HH:mm:ss dd.MM.yyyy',
}

** LocaleName is exported by fwc-date. See date-fns Locale for all supported locales.

type LocaleName = 'enGB' | 'enUS' | 'nb' | ...;

Range <fwc-daterange>

Example Usage

Relative

return (
  <fwc-daterange variant='relative' date='2021-08-09T09:12:49Z' baseDate='2021-08-09T11:12:49Z' />
);

Distance

return (
  <fwc-daterange variant='distance' date='2021-08-09T09:12:49Z' baseDate='2021-08-09T11:12:49Z' />
);

Date & Time (From - To)

return (
  <fwc-daterange
    variant='datetime'
    format={DateTimeFormat.datetime}
    date='2021-08-09T09:12:49Z'
    baseDate='2021-08-09T11:12:49Z'
  />
);

Date & Time with custom separator

return (
  <fwc-daterange
    variant='datetime'
    format={DateTimeFormat.datetime}
    date='2021-08-09T09:12:49Z'
    baseDate='2021-08-09T11:12:49Z'
  >
  <span slot='separator'>to</span>
  </fwc-daterange>
);

With custom locale property

return (
  <fwc-daterange
    variant='datetime'
    format={DateTimeFormat.datetime}
    date='2021-08-09T09:12:49Z'
    baseDate='2021-08-09T11:12:49Z'
    locale='nb'
  >
  <span slot='separator'>to</span>
  </fwc-daterange>
);

Slots

NameDefaultDescription
separator<span>-</span>Separator element to render between from and to dates for variant datetime.

Properties/Attributes

NameTypeDefaultDescription
fromstringcurrent dateThe date to format in ISO format. See 'ISO_8601'.
tostringcurrent dateThe date to compare with in ISO format. See 'ISO_8601'.
variantDateRangeVariant*datetimeTemplated variant to use as basis for format calculation, defaults to datetime (HH:mm dd.MM.yyyy - HH:mm dd.MM.yyyy).
formatDateTimeFormat** or stringundefinedPredefined or custom format to use. Based on Unicode Technical Standard #35.
localeLocaleName***enGBUsed to override the locale for which the date format is based. See date-fns Locale.
secondsbooleanfalseSet true to include seconds in the distance variant.
weekstartWeekDay****1The index of the first day of the week (0 = Sunday).
suffixbooleanfalseInclude a suffix to indicate if the date is before or after the baseDate. Only applies to variant distance.
capitalizebooleanfalseSet true to capitalize the first character in the formatted text. Applies to distance and relative variants.

* DateRangeVariant is exported by fwc-date.

type DateRangeVariant = 'relative' | 'distance' | 'datetime';

** DateTimeFormat is exported by fwc-date.

enum DateTimeFormat {
  date = 'dd.MM.yyyy',
  time = 'HH:mm',
  datetime = 'HH:mm dd.MM.yyyy',
  time_with_seconds = 'HH:mm:ss',
  datetime_with_seconds = 'HH:mm:ss dd.MM.yyyy',
}

*** LocaleName is exported by fwc-date. See date-fns Locale for all supported locales.

type LocaleName = 'enGB' | 'enUS' | 'nb' | ...;

**** WeekDay is exported by fwc-date.

type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6;

版本与发布记录

@equinor/fusion-wc-date 共发布 43 个版本,首次发布于 2021/08/12;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.2.5latest2026/10/2224 天前
1.2.42026/08/123 个月前
1.2.32026/05/116 个月前
1.2.22026/05/056 个月前
1.2.12026/04/286 个月前
1.2.02026/04/206 个月前

其他发布通道:next → 0.2.28-next.1。

关于 @equinor/fusion-wc-date 的常见问题

@equinor/fusion-wc-date 是什么?

## `fusion-wc-date` [![Published on npm](https://img.shields.io/npm/v/@equinor/fusion-wc-date.svg)](https://www.npmjs.com/package/@equinor/fusion-wc-date)

如何安装 @equinor/fusion-wc-date?

在项目目录运行 npm install @equinor/fusion-wc-date,或使用 pnpm add / yarn add / bun add。

@equinor/fusion-wc-date 支持 TypeScript 吗?

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

@equinor/fusion-wc-date 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@equinor/fusion-wc-date 可以商用吗?

@equinor/fusion-wc-date 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@equinor/fusion-wc-date 的下载量有多少?

根据 npm 官方下载统计,@equinor/fusion-wc-date 在 2026/10/14 – 2026/11/12 这 30 天内被下载 1,971 次,日均约 66 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@equinor/fusion-wc-date 还在维护吗?

最新版本 1.2.5 发布于 2026/10/22(24 天前);至今共发布 43 个版本,其中过去 12 个月发布了 6 个;首次发布于 2021/08/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。