# @gechiui/date

> Date module for GeChiUI.

Latest version **4.3.1** (published 2022-03-17) · GPL-2.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @gechiui/date
pnpm add @gechiui/date
yarn add @gechiui/date
bun add @gechiui/date
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.3.1 |
| Published | 2022-03-17 |
| First published | 2022-03-17 |
| Weekly downloads | 0 |
| License | GPL-2.0-or-later |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=12 |
| Dependencies | 3 |
| Unpacked size | 175.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | The GeChiUI Contributors |
| Maintainers | gechiui |
| Keywords | gechiui, gutenberg, date |

## Links

- npm: https://www.npmjs.com/package/@gechiui/date
- Repository: https://github.com/GeChiUI/gutenberg
- Homepage: https://github.com/GeChiUI/gutenberg/tree/HEAD/packages/date/README.md
- Issues: https://github.com/GeChiUI/gutenberg/issues
- npm.io page: https://npm.io/package/@gechiui/date

## Dependencies (3)

- [moment](https://npm.io/package/moment.md) ^2.22.1
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.16.0
- [moment-timezone](https://npm.io/package/moment-timezone.md) ^0.5.31

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 4.3.1 (latest) — 2022-03-17
- 4.2.3 — 2022-03-17

## README

# Date

Date module for GeChiUI.

## Installation

Install the module

```bash
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`](https://github.com/GeChiUI/gutenberg/tree/HEAD/packages/babel-preset-default#polyfill) in your code._

## API

<!-- START TOKEN(Autogenerated API docs) -->

### date

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

_Related_

-   <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>
-   <https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC>

_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_

-   <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones>
-   <https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC>

_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.

<!-- END TOKEN(Autogenerated API docs) -->

## 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](https://www.npmjs.com/) and used by [GeChiUI](https://make.gechiui.com/core/) 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](https://github.com/GeChiUI/gutenberg/tree/HEAD/CONTRIBUTING.md).

<br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>

---
_Source: https://npm.io/package/@gechiui/date · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
