@gechiui/date
TypeScript icon, indicating that this package has built-in type declarations

4.3.1 • Public • Published

Date

Date module for GeChiUI.

Installation

Install the module

npm install @gechiui/date --save

This package assumes that your code will run in an ES2015+ environment. If you're using an environment that has limited or no support for such language features and APIs, you should include the polyfill shipped in @gechiui/babel-preset-default in your code.

API

date

Formats a date (like date() in PHP).

Related

Parameters

  • dateFormat string: PHP-style formatting string. See php.net/date.
  • dateValue Moment | Date | string | undefined: Date object or string, parsable by moment.js.
  • timezone string | undefined: Timezone to output result in or a UTC offset. Defaults to timezone from site.

Returns

  • string: Formatted date in English.

dateI18n

Formats a date (like gc_date() in PHP), translating it into site's locale.

Backward Compatibility Notice: if timezone is set to true, the function behaves like gmdateI18n.

Related

Parameters

  • dateFormat string: PHP-style formatting string. See php.net/date.
  • dateValue Moment | Date | string | undefined: Date object or string, parsable by moment.js.
  • timezone string | boolean | undefined: Timezone to output result in or a UTC offset. Defaults to timezone from site. Notice: boolean is effectively deprecated, but still supported for backward compatibility reasons.

Returns

  • string: Formatted date.

format

Formats a date. Does not alter the date's timezone.

Parameters

  • dateFormat string: PHP-style formatting string. See php.net/date.
  • dateValue Moment | Date | string | undefined: Date object or string, parsable by moment.js.

Returns

  • string: Formatted date.

getDate

Create and return a JavaScript Date Object from a date string in the GC timezone.

Parameters

  • dateString string?: Date formatted in the GC timezone.

Returns

  • Date: Date

gmdate

Formats a date (like date() in PHP), in the UTC timezone.

Parameters

  • dateFormat string: PHP-style formatting string. See php.net/date.
  • dateValue Moment | Date | string | undefined: Date object or string, parsable by moment.js.

Returns

  • string: Formatted date in English.

gmdateI18n

Formats a date (like gc_date() in PHP), translating it into site's locale and using the UTC timezone.

Parameters

  • dateFormat string: PHP-style formatting string. See php.net/date.
  • dateValue Moment | Date | string | undefined: Date object or string, parsable by moment.js.

Returns

  • string: Formatted date.

isInTheFuture

Check whether a date is considered in the future according to the GeChiUI settings.

Parameters

  • dateValue string: Date String or Date object in the Defined GC Timezone.

Returns

  • boolean: Is in the future.

setSettings

Adds a locale to moment, using the format supplied by gc_localize_script().

Parameters

  • dateSettings DateSettings: Settings, including locale data.

Contributing to this package

This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to npm and used by GeChiUI as well as other software projects.

To find out more about contributing to this package or Gutenberg as a whole, please read the project's main contributor guide.



Code is Poetry.

Dependents (3)

Package Sidebar

Install

npm i @gechiui/date

Weekly Downloads

0

Version

4.3.1

License

GPL-2.0-or-later

Unpacked Size

179 kB

Total Files

14

Last publish

Collaborators

  • gechiui