-
Notifications
You must be signed in to change notification settings - Fork 835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create moment in zone from time-only uses wrong date #297
Comments
Confirmed. Thanks for the bug report, we'll fix this asap. Also, note you should probably be using |
Looks like the problem is here: function tz (input) {
var args = Array.prototype.slice.call(arguments, 0, -1),
name = arguments[arguments.length - 1],
zone = getZone(name),
out = moment.utc.apply(null, args); // <--------- here
if (zone && !moment.isMoment(input) && needsOffset(out)) {
out.add(zone.parse(out), 'minutes');
}
out.tz(name);
return out;
} Because the In other words, it fails whenever the current UTC date is not the current date in the specified time zone. Eluding me on how to fix at the moment. I'd prefer a solution that gets the original value correctly ahead of time, but all I can come up with is an approach for correcting after-the-fact. Ideas @timrwood ? |
This is the same issue as #119, and requires changes to moment core to fix. |
I think moment/moment-rfcs#1 could help provide a solution to this. |
Is this still a known problem? I've been getting the wrong day when creating a moment with just a time. I've done a workaround - written a function that takes in the correct day and the desired time and returns a moment. |
In node.js running on Amazon Lambda:
where UTC date is "2016-02-01"
var date= moment.tz('03:00','hh:mm', 'America/Chicago');
returns 2016-02-01T03:00:00-06:00 instead of =2016-01-31T03:00:00-06:00
Thanks
The text was updated successfully, but these errors were encountered: