Skip to content

Commit

Permalink
fix: timeZoneFromOffset function to return correct offset for UTC tim…
Browse files Browse the repository at this point in the history
…ezone (#437)
  • Loading branch information
shumeiko authored Sep 20, 2024
1 parent 05ff875 commit c8b43a6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/node/transforms/__specs__/format.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ describe('transform/format', () => {

it('timeZoneFromOffset', () => {
expect(format.timeZoneFromOffset(-60)).toBe('+01:00');
expect(format.timeZoneFromOffset(0)).toBe('+00:00');
expect(format.timeZoneFromOffset(60)).toBe('-01:00');
expect(format.timeZoneFromOffset(-570)).toBe('+09:30');
});
Expand Down
2 changes: 1 addition & 1 deletion src/node/transforms/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function concatFirstStringElements({ data }) {

function timeZoneFromOffset(minutesOffset) {
const minutesPositive = Math.abs(minutesOffset);
const sign = minutesOffset >= 0 ? '-' : '+';
const sign = minutesOffset > 0 ? '-' : '+';
const hours = Math.floor(minutesPositive / 60).toString().padStart(2, '0');
const minutes = (minutesPositive % 60).toString().padStart(2, '0');
return `${sign}${hours}:${minutes}`;
Expand Down

0 comments on commit c8b43a6

Please sign in to comment.