Skip to content

Commit d6924f7

Browse files
authored
feat(date)!: separate timeZone method (#2947)
1 parent 5801cc5 commit d6924f7

File tree

13 files changed

+560
-426
lines changed

13 files changed

+560
-426
lines changed

docs/guide/upgrading.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,15 @@ Now, this throws an error raising awareness of that bad value.
567567

568568
This affects the `refDate` parameter of the `anytime()`, `birthdate()`, `past()`, `future()`, `recent()` and `soon()`, methods as well as the `from` and `to` parameters of `between()` and `betweens()`.
569569

570+
### Separate Timezone Methods
571+
572+
The `timeZone` functionality has been divided to enhance specificity:
573+
574+
- Use `faker.date.timeZone()` to generate a random global time zone.
575+
- Use `faker.location.timeZone()` to obtain time zone specific to the current locale.
576+
577+
We haven't updated all locale dependent time zone data yet, so if you encounter unexpected values, please create a new issue.
578+
570579
### Prices Now Return More Price-Like Values
571580

572581
The `faker.commerce.price()` method now produces values that also return fractional values.

src/definitions/date.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ export type DateDefinition = LocaleEntry<{
1313
* The translations for weekdays (Sunday - Saturday).
1414
*/
1515
weekday: DateEntryDefinition;
16+
17+
/**
18+
* The names of the IANA time zones. Not tied to the current locale.
19+
*
20+
* Since this is the same for all locales, it is only defined in the `base` locale.
21+
*
22+
* @see [IANA Time Zone Database](https://www.iana.org/time-zones)
23+
*/
24+
time_zone: string[];
1625
}>;
1726

1827
/**

src/definitions/location.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ export type LocationDefinition = LocaleEntry<{
137137
secondary_address: string[];
138138

139139
/**
140-
* A list of timezones names.
140+
* A list of time zones names relevant to this locale.
141+
*
142+
* @see [IANA Time Zone Database](https://www.iana.org/time-zones)
141143
*/
142144
time_zone: string[];
143145
}>;

src/locales/base/date/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* This file is automatically generated.
3+
* Run 'pnpm run generate:locales' to update.
4+
*/
5+
import type { DateDefinition } from '../../..';
6+
import time_zone from './time_zone';
7+
8+
const date: DateDefinition = {
9+
time_zone,
10+
};
11+
12+
export default date;

0 commit comments

Comments
 (0)