Skip to content

Commit

Permalink
Fix for #39 (Bug when specify partial hour timezone)
Browse files Browse the repository at this point in the history
Changed calculation of timezone offset in minutes
Added round and abs for partial hour
  • Loading branch information
alexandrnikitin committed Jun 17, 2014
1 parent eedbb8b commit dfeb3f8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions strftime.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
var sign = tz[0] == '-' ? -1 : 1;
var hours = parseInt(tz.slice(1, 3), 10);
var mins = parseInt(tz.slice(3, 5), 10);
tz = sign * (60 * hours) + mins;
tz = sign * ((60 * hours) + mins);
}

if (tzType) {
Expand Down Expand Up @@ -271,7 +271,7 @@
}
else {
var off = typeof tz == 'number' ? tz : -d.getTimezoneOffset();
return (off < 0 ? '-' : '+') + pad(Math.abs(off / 60)) + pad(off % 60);
return (off < 0 ? '-' : '+') + pad(Math.floor(Math.abs(off) / 60)) + pad(Math.abs(off) % 60);
}

default: return c;
Expand Down

0 comments on commit dfeb3f8

Please sign in to comment.