aboutsummaryrefslogtreecommitdiff
path: root/lib/time.js
diff options
context:
space:
mode:
authorLuiz Strobelt <[email protected]>2020-10-01 00:28:36 -0300
committerGitHub <[email protected]>2020-10-01 00:28:36 -0300
commit5df3678f842383855c53a4c14d39a20deb64f7cc (patch)
tree3b9fb614af27c68cfae7cdf76929069f8935ec0c /lib/time.js
parent27f4878ab3d989cdddec9df99802fe2150730ba2 (diff)
parent91dc8a3372426bc691be56153b33e81a16459f49 (diff)
downloadfaker-5df3678f842383855c53a4c14d39a20deb64f7cc.tar.xz
faker-5df3678f842383855c53a4c14d39a20deb64f7cc.zip
Merge pull request #1 from Marak/master
Update to latest base branch
Diffstat (limited to 'lib/time.js')
-rw-r--r--lib/time.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/time.js b/lib/time.js
new file mode 100644
index 00000000..580d33ee
--- /dev/null
+++ b/lib/time.js
@@ -0,0 +1,37 @@
+/**
+ *
+ * @namespace faker.time
+ */
+var _Time = function(faker) {
+ var self = this;
+
+ /**
+ * recent
+ *
+ * @method faker.time.recent
+ * @param {string} outputType - 'abbr' || 'wide' || 'unix' (default choice)
+ */
+ self.recent = function(outputType) {
+ if (typeof outputType === "undefined") {
+ outputType = 'unix';
+ }
+
+ var date = new Date();
+ switch (outputType) {
+ case "abbr":
+ date = date.toLocaleTimeString();
+ break;
+ case "wide":
+ date = date.toTimeString();
+ break;
+ case "unix":
+ date = date.getTime();
+ break;
+ }
+ return date;
+ };
+
+ return self;
+};
+
+module["exports"] = _Time;