Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

date: set up auto-generated API docs #14276

Merged
merged 3 commits into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/update-readmes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const packages = [
'blocks',
'compose',
//'data',
//'date',
'date',
'deprecated',
'dom',
'dom-ready',
Expand Down
106 changes: 106 additions & 0 deletions packages/date/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,110 @@ npm install @wordpress/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 ES2015+ such as lower versions of IE then using [core-js](https://github.com/zloirock/core-js) or [@babel/polyfill](https://babeljs.io/docs/en/next/babel-polyfill) will add support for these methods. Learn more about it in [Babel docs](https://babeljs.io/docs/en/next/caveats)._

## API

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

### date

[src/index.js#L323-L327](src/index.js#L323-L327)

Formats a date (like `date()` in PHP), in the site's timezone.

**Parameters**

- **dateFormat** `string`: PHP-style formatting string. See php.net/date.
- **dateValue** `(Date|string|moment|null)`: Date object or string, parsable by moment.js.

**Returns**

`string`: Formatted date.

### dateI18n

[src/index.js#L356-L366](src/index.js#L356-L366)

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

**Parameters**

- **dateFormat** `string`: PHP-style formatting string. See php.net/date.
- **dateValue** `(Date|string|moment|null)`: Date object or string, parsable by moment.js.
- **gmt** `boolean`: True for GMT/UTC, false for site's timezone.

**Returns**

`string`: Formatted date.

### format

[src/index.js#L282-L311](src/index.js#L282-L311)

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

**Parameters**

- **dateFormat** `string`: PHP-style formatting string. See php.net/date.
- **dateValue** `(Date|string|moment|null)`: Date object or string, parsable by moment.js.

**Returns**

`string`: Formatted date.

### getDate

[src/index.js#L389-L395](src/index.js#L389-L395)

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

**Parameters**

- **dateString** `?string`: Date formatted in the WP timezone.

**Returns**

`Date`: Date

### gmdate

[src/index.js#L339-L342](src/index.js#L339-L342)

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

**Parameters**

- **dateFormat** `string`: PHP-style formatting string. See php.net/date.
- **dateValue** `(Date|string|moment|null)`: Date object or string, parsable by moment.js.

**Returns**

`string`: Formatted date.

### isInTheFuture

[src/index.js#L375-L380](src/index.js#L375-L380)

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

**Parameters**

- **dateValue** `string`: Date String or Date object in the Defined WP Timezone.

**Returns**

`boolean`: Is in the future.

### setSettings

[src/index.js#L36-L83](src/index.js#L36-L83)

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

**Parameters**

- **dateSettings** `Object`: Settings, including locale data.


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

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