不要怂,就是干,撸起袖子干!

Commit 1746048f by Will Anderson Committed by Jan Aagaard Meier

utcOffset fix (#5588)

1 parent 6a6be9e9
Showing with 7 additions and 6 deletions
......@@ -7,7 +7,8 @@ var util = require('util')
, sequelizeErrors = require('./errors')
, warnings = {}
, Validator = require('validator')
, moment = require('moment-timezone');
, momentTz = require('moment-timezone')
, moment = require('moment');
/**
* A convenience class holding commonly used data types. The datatypes are used when defining a new model using `Sequelize.define`, like this:
......@@ -463,14 +464,14 @@ DATE.prototype.validate = function(value) {
};
DATE.prototype.$applyTimezone = function (date, options) {
date = moment(date);
if (options.timezone) {
if (moment.tz.zone(options.timezone)) {
date = date.tz(options.timezone);
if (momentTz.tz.zone(options.timezone)) {
date = momentTz(date).tz(options.timezone);
} else {
date = date.utcOffset(options.timezone);
date = moment(date).utcOffset(options.timezone);
}
} else {
date = momentTz(date);
}
return date;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!