dry-underscore
Advanced tools
Comparing version 0.21.6 to 0.21.7
@@ -229,9 +229,12 @@ "use strict"; | ||
_.isoDate = _.iso_date = function(d){ | ||
_.isoDate = _.iso_date = function(d, tz){ | ||
if(d === undefined){ d = _.date(); } | ||
var iso_format = "YYYY-MM-DD"; | ||
if(d && tz){ return(_.moment.tz(d, iso_format, true, tz)); } | ||
if(_.isString(d)){ | ||
if(_.moment.tz && _.moment.tz.zone(d)){ | ||
return(_.moment.tz(d).format("YYYY-MM-DD")); | ||
}else{ | ||
var m = _.moment(d, "YYYY-MM-DD", true); | ||
if(_.moment.tz && _.moment.tz.zone(d)){ return(_.moment.tz(d).format(iso_format)); } | ||
else{ | ||
var m = _.moment(d, iso_format, true); | ||
if(m.isValid()){ return(m); } | ||
@@ -241,3 +244,3 @@ else{ return(null); } | ||
} | ||
return(_.moment(d).format("YYYY-MM-DD")); | ||
return(_.moment(d).format(iso_format)); | ||
}; | ||
@@ -244,0 +247,0 @@ |
"use strict"; | ||
var _ = require('../'); | ||
var _ = require('../../'); | ||
@@ -12,3 +12,3 @@ var root = _.path.fun(__dirname); | ||
var test_server = require('../test_server/server.tjs'); | ||
var test_server = require('../../test_server/server.tjs'); | ||
@@ -15,0 +15,0 @@ before(test_server.start_server); |
"use strict"; | ||
var _ = require('../'); | ||
var _ = require('../../'); | ||
@@ -29,13 +29,35 @@ var eq = _.test.eq; | ||
var now_la = _.moment.tz("America/Los_Angeles"); | ||
var la_tz = "America/Los_Angeles"; | ||
var ny_tz = "America/New_York"; | ||
var now_la = _.moment.tz(la_tz); | ||
var now_la_iso_date = now_la.format("YYYY-MM-DD"); | ||
eq(now_la_iso_date, _.iso_date("America/Los_Angeles")); | ||
eq(now_la_iso_date, _.iso_date(la_tz)); | ||
_.p("tonga date: ", _.iso_date("Pacific/Tongatapu")); | ||
_.p("tonga time: ", _.moment.tz("Pacific/Tongatapu").format()); | ||
_.p("samoa date: ", _.iso_date("Pacific/Samoa")); | ||
_.p("samoa time: ", _.moment.tz("Pacific/Samoa").format()); | ||
_.p(_.iso_date("Pacific/Tongatapu") + " !== " + _.iso_date("Pacific/Samoa")); | ||
var other_tz = la_tz; | ||
var current_tz = _.moment.tz.guess(); | ||
ok(_.iso_date("Pacific/Tongatapu") !== _.iso_date("Pacific/Samoa")) | ||
if(current_tz === la_tz){ other_tz = ny_tz; } | ||
var date = "2016-01-02"; | ||
var wrong = _.moment(date, "YYYY-MM-DD").tz(other_tz); | ||
var right = _.moment.tz(date, "YYYY-MM-DD", other_tz); | ||
ok(_.iso_date(date).tz(other_tz).isSame(wrong)); | ||
ok(!_.iso_date(date).tz(other_tz).isSame(right)); | ||
ok(_.iso_date(date, other_tz).isSame(right)); | ||
ok(!_.iso_date(date, other_tz).isSame(wrong)); | ||
var tonga_tz = "Pacific/Tongatapu"; | ||
var samoa_tz = "Pacific/Samoa"; | ||
_.p("tonga date: ", _.iso_date(tonga_tz)); | ||
_.p("tonga time: ", _.moment.tz(tonga_tz).format()); | ||
_.p("samoa date: ", _.iso_date(samoa_tz)); | ||
_.p("samoa time: ", _.moment.tz(samoa_tz).format()); | ||
_.p(_.iso_date(tonga_tz) + " !== " + _.iso_date(samoa_tz)); | ||
ok(_.iso_date(tonga_tz) !== _.iso_date(samoa_tz)); | ||
}); | ||
@@ -42,0 +64,0 @@ |
"use strict"; | ||
var _ = require('../'); | ||
var _ = require('../../'); | ||
@@ -5,0 +5,0 @@ var root = _.path.fun(__dirname); |
{ | ||
"name": "dry-underscore", | ||
"version": "0.21.6", | ||
"version": "0.21.7", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "deep-diff": { |
{ | ||
"name": "dry-underscore", | ||
"version": "0.21.6", | ||
"version": "0.21.7", | ||
"main": "./index/node.index.js", | ||
@@ -5,0 +5,0 @@ "description": "The DRY Undescore Library", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1922923
23274