aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormkg0 <[email protected]>2020-08-18 14:51:44 +0200
committermkg0 <[email protected]>2020-08-18 14:51:44 +0200
commitb08f11c347ae4a5a39ac145ea3620fe754bb9e0d (patch)
tree09b5b20996dd653849e4ded6512bd538e3b1de6f
parent7da419dd8cd94ca8726d757b48645683fe25c0fc (diff)
downloadfaker-b08f11c347ae4a5a39ac145ea3620fe754bb9e0d.tar.xz
faker-b08f11c347ae4a5a39ac145ea3620fe754bb9e0d.zip
add time_zone
-rw-r--r--lib/address.js8
-rw-r--r--lib/index.js2
-rw-r--r--test/address.unit.js10
3 files changed, 19 insertions, 1 deletions
diff --git a/lib/address.js b/lib/address.js
index 6ac5f9b9..125e3d50 100644
--- a/lib/address.js
+++ b/lib/address.js
@@ -373,6 +373,14 @@ function Address (faker) {
return [randomCoord[0].toFixed(4), randomCoord[1].toFixed(4)];
}
+ /**
+ * Return a random time zone
+ * @method faker.address.timeZone
+ */
+ this.timeZone = function() {
+ return faker.random.arrayElement(faker.definitions.address.time_zone);
+ }
+
return this;
}
diff --git a/lib/index.js b/lib/index.js
index c9c00d9c..764afec5 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -100,7 +100,7 @@ function Faker (opts) {
var _definitions = {
"name": ["first_name", "last_name", "prefix", "suffix", "gender", "title", "male_prefix", "female_prefix", "male_first_name", "female_first_name", "male_middle_name", "female_middle_name", "male_last_name", "female_last_name"],
- "address": ["city_prefix", "city_suffix", "street_suffix", "county", "country", "country_code", "state", "state_abbr", "street_prefix", "postcode", "postcode_by_state", "direction", "direction_abbr"],
+ "address": ["city_prefix", "city_suffix", "street_suffix", "county", "country", "country_code", "state", "state_abbr", "street_prefix", "postcode", "postcode_by_state", "direction", "direction_abbr", "time_zone"],
"company": ["adjective", "noun", "descriptor", "bs_adjective", "bs_noun", "bs_verb", "suffix"],
"lorem": ["words"],
"hacker": ["abbreviation", "adjective", "noun", "verb", "ingverb", "phrase"],
diff --git a/test/address.unit.js b/test/address.unit.js
index d63cb78c..3d1e5770 100644
--- a/test/address.unit.js
+++ b/test/address.unit.js
@@ -509,4 +509,14 @@ describe("address.js", function () {
});
});
+ describe("timeZone()", function () {
+ it("returns random timeZone", function () {
+ sinon.spy(faker.address, 'timeZone');
+ var timeZone = faker.address.timeZone();
+ assert.ok(timeZone);
+ assert.ok(faker.address.timeZone.called);
+ faker.address.timeZone.restore();
+ });
+ });
+
});