Skip to content

Commit 25bd8b4

Browse files
manzoorwanijkmanzoorwanijkdmsnell
authored
Convert date package to TypeScript (#67665)
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org> Co-authored-by: dmsnell <dmsnell@git.wordpress.org>
1 parent 2e1abeb commit 25bd8b4

File tree

4 files changed

+275
-159
lines changed

4 files changed

+275
-159
lines changed

packages/date/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Enhancements
6+
7+
- Improved TypeScript definitions ([67573](https://github.com/WordPress/gutenberg/pull/67573))
8+
59
## 5.29.0 (2025-08-20)
610

711
## 5.28.0 (2025-08-07)

packages/date/README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ _Related_
2828
_Parameters_
2929

3030
- _dateFormat_ `string`: PHP-style formatting string. See [php.net/date](https://www.php.net/manual/en/function.date.php).
31-
- _dateValue_ `Moment | Date | string | undefined`: Date object or string, parsable by moment.js.
32-
- _timezone_ `string | number | undefined`: Timezone to output result in or a UTC offset. Defaults to timezone from site.
31+
- _dateValue_ `Moment | Date | string | number`: Date object or string, parsable by moment.js.
32+
- _timezone_ `string`: Timezone to output result in or a UTC offset. Defaults to timezone from site.
3333

3434
_Returns_
3535

@@ -49,12 +49,12 @@ _Related_
4949
_Parameters_
5050

5151
- _dateFormat_ `string`: PHP-style formatting string. See [php.net/date](https://www.php.net/manual/en/function.date.php).
52-
- _dateValue_ `Moment | Date | string | undefined`: Date object or string, parsable by moment.js.
53-
- _timezone_ `string | number | 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.
52+
- _dateValue_ `Moment | Date | string | number`: Date object or string, parsable by moment.js.
53+
- _timezone_ `string | number | boolean`: 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.
5454

5555
_Returns_
5656

57-
- `string`: Formatted date.
57+
- Formatted date.
5858

5959
### format
6060

@@ -63,23 +63,23 @@ Formats a date. Does not alter the date's timezone.
6363
_Parameters_
6464

6565
- _dateFormat_ `string`: PHP-style formatting string. See [php.net/date](https://www.php.net/manual/en/function.date.php).
66-
- _dateValue_ `Moment | Date | string | undefined`: Date object or string, parsable by moment.js.
66+
- _dateValue_ `Moment | Date | string | number`: Date object or string, parsable by moment.js.
6767

6868
_Returns_
6969

70-
- `string`: Formatted date.
70+
- Formatted date.
7171

7272
### getDate
7373

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

7676
_Parameters_
7777

78-
- _dateString_ `?string`: Date formatted in the WP timezone.
78+
- _dateString_ `string | null`: Date formatted in the WP timezone.
7979

8080
_Returns_
8181

82-
- `Date`: Date
82+
- Date
8383

8484
### getSettings
8585

@@ -96,11 +96,11 @@ Formats a date (like `date()` in PHP), in the UTC timezone.
9696
_Parameters_
9797

9898
- _dateFormat_ `string`: PHP-style formatting string. See [php.net/date](https://www.php.net/manual/en/function.date.php).
99-
- _dateValue_ `Moment | Date | string | undefined`: Date object or string, parsable by moment.js.
99+
- _dateValue_ `Moment | Date | string | number`: Date object or string, parsable by moment.js.
100100

101101
_Returns_
102102

103-
- `string`: Formatted date in English.
103+
- Formatted date in English.
104104

105105
### gmdateI18n
106106

@@ -109,36 +109,36 @@ Formats a date (like `wp_date()` in PHP), translating it into site's locale and
109109
_Parameters_
110110

111111
- _dateFormat_ `string`: PHP-style formatting string. See [php.net/date](https://www.php.net/manual/en/function.date.php).
112-
- _dateValue_ `Moment | Date | string | undefined`: Date object or string, parsable by moment.js.
112+
- _dateValue_ `Moment | Date | string | number`: Date object or string, parsable by moment.js.
113113

114114
_Returns_
115115

116-
- `string`: Formatted date.
116+
- Formatted date.
117117

118118
### humanTimeDiff
119119

120120
Returns a human-readable time difference between two dates, like human_time_diff() in PHP.
121121

122122
_Parameters_
123123

124-
- _from_ `Moment | Date | string`: From date, in the WP timezone.
125-
- _to_ `Moment | Date | string | undefined`: To date, formatted in the WP timezone.
124+
- _from_ `Moment | Date | string | number`: From date, in the WP timezone.
125+
- _to_ `Moment | Date | string | number`: To date, formatted in the WP timezone.
126126

127127
_Returns_
128128

129-
- `string`: Human-readable time difference.
129+
- Human-readable time difference.
130130

131131
### isInTheFuture
132132

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

135135
_Parameters_
136136

137-
- _dateValue_ `string`: Date String or Date object in the Defined WP Timezone.
137+
- _dateValue_ `Date | string | number`: Date String or Date object in the Defined WP Timezone.
138138

139139
_Returns_
140140

141-
- `boolean`: Is in the future.
141+
- Is in the future.
142142

143143
### setSettings
144144

0 commit comments

Comments
 (0)