aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2024-06-21 11:44:57 +0200
committerGitHub <[email protected]>2024-06-21 09:44:57 +0000
commitd6924f7fbb9403d106022f58a1bda3b159e88ae6 (patch)
tree36ed943a8ea837a4538073c7e51b6ed831cb190d /src/modules
parent5801cc5cad8324a114d08733fafa31f7632d1118 (diff)
downloadfaker-d6924f7fbb9403d106022f58a1bda3b159e88ae6.tar.xz
faker-d6924f7fbb9403d106022f58a1bda3b159e88ae6.zip
feat(date)!: separate timeZone method (#2947)
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/date/index.ts19
-rw-r--r--src/modules/location/index.ts7
2 files changed, 25 insertions, 1 deletions
diff --git a/src/modules/date/index.ts b/src/modules/date/index.ts
index 10196d6e..f2eac1cf 100644
--- a/src/modules/date/index.ts
+++ b/src/modules/date/index.ts
@@ -685,4 +685,23 @@ export class DateModule extends SimpleDateModule {
assertLocaleData(values, 'date.weekday', type);
return this.faker.helpers.arrayElement(values);
}
+
+ /**
+ * Returns a random IANA time zone name.
+ *
+ * The returned time zone is not tied to the current locale.
+ *
+ * @see [IANA Time Zone Database](https://www.iana.org/time-zones)
+ * @see faker.location.timeZone(): For generating a timezone based on the current locale.
+ *
+ * @example
+ * faker.location.timeZone() // 'Pacific/Guam'
+ *
+ * @since 9.0.0
+ */
+ timeZone(): string {
+ return this.faker.helpers.arrayElement(
+ this.faker.definitions.date.time_zone
+ );
+ }
}
diff --git a/src/modules/location/index.ts b/src/modules/location/index.ts
index 8fbbbe30..d55e0c8a 100644
--- a/src/modules/location/index.ts
+++ b/src/modules/location/index.ts
@@ -596,7 +596,12 @@ export class LocationModule extends ModuleBase {
}
/**
- * Returns a random time zone.
+ * Returns a random IANA time zone relevant to this locale.
+ *
+ * The returned time zone is tied to the current locale.
+ *
+ * @see [IANA Time Zone Database](https://www.iana.org/time-zones)
+ * @see faker.date.timeZone(): For generating a random time zone from all available time zones.
*
* @example
* faker.location.timeZone() // 'Pacific/Guam'