// a second time. In case it wants us to change the offset again
// _changeInProgress == true case, then we have to adjust, because
// there is no such time in the given timezone.
-export function getSetOffset (input, keepLocalTime) {
+export function getSetOffset (input, keepLocalTime, keepMinutes) {
var offset = this._offset || 0,
localAdjust;
if (!this.isValid()) {
if (input === null) {
return this;
}
- } else if (Math.abs(input) < 16) {
+ } else if (Math.abs(input) < 16 && !keepMinutes) {
input = input * 60;
}
if (!this._isUTC && keepLocalTime) {
export function setOffsetToParsedOffset () {
if (this._tzm != null) {
- this.utcOffset(this._tzm);
+ this.utcOffset(this._tzm, false, true);
} else if (typeof this._i === 'string') {
var tZone = offsetFromString(matchOffset, this._i);
if (tZone != null) {
'Not providing a timezone should keep the time and change the zone to 0'
);
});
+
+test('parse zone with a minutes unit abs less than 16 should retain minutes', function (assert) {
+ //ensure when minutes are explicitly parsed, they are retained
+ //instead of converted to hours, even if less than 16
+ var n = moment.parseZone('2013-01-01T00:00:00-00:15');
+ assert.equal(n.utcOffset(), -15);
+ assert.equal(n.zone(), 15);
+ assert.equal(n.hour(), 0);
+ var o = moment.parseZone('2013-01-01T00:00:00+00:15');
+ assert.equal(o.utcOffset(), 15);
+ assert.equal(o.zone(), -15);
+ assert.equal(o.hour(), 0);
+});