Skip to content

Commit

Permalink
Fix for timezones with Offsets which have offset in minutes not divis…
Browse files Browse the repository at this point in the history
…ible by 60. (#1599)

For Indian Timezone +05:30 or 330 minutes the output becomes +5.5:30 but as per ISO 8601 standard it should be +05:30. hourOffset should be "05" and minute offset should be "30" but currently hourOffset is set to "5.5"
  • Loading branch information
dcRUSTy committed Feb 18, 2020
1 parent fc684d6 commit df3e00b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/formatISO/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default function formatISO(dirtyDate, dirtyOptions) {

if (offset !== 0) {
const absoluteOffset = Math.abs(offset)
const hourOffset = addLeadingZeros(absoluteOffset / 60, 2)
const hourOffset = addLeadingZeros(Math.floor(absoluteOffset / 60), 2)
const minuteOffset = addLeadingZeros(absoluteOffset % 60, 2)
// If less than 0, the sign is +, because it is ahead of time.
const sign = offset < 0 ? '+' : '-'
Expand Down
2 changes: 1 addition & 1 deletion src/formatISO/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function generateOffset(originalDate) {

if (tzOffset !== 0) {
const absoluteOffset = Math.abs(tzOffset)
const hourOffset = addLeadingZeros(absoluteOffset / 60, 2)
const hourOffset = addLeadingZeros(Math.floor(absoluteOffset / 60), 2)
const minuteOffset = addLeadingZeros(absoluteOffset % 60, 2)
// If less than 0, the sign is +, because it is ahead of time.
const sign = tzOffset < 0 ? '+' : '-'
Expand Down

0 comments on commit df3e00b

Please sign in to comment.