Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Timezone offset bug #1261

Closed
benpriebe opened this issue Aug 13, 2012 · 2 comments
Closed

Timezone offset bug #1261

benpriebe opened this issue Aug 13, 2012 · 2 comments

Comments

@benpriebe
Copy link

When I hit my site from a +1000 timezone and run the date through a $filter with the Z timezone formatter I get a -1000 timezone.

e.g.

var now = new Date(); // Fri Aug 10 2012 14:00:00 GMT+1000
var created = $filter('date')(now, "yyyy-MM-ddTHH:mm:ss.000Z");

Which equals:

"2012-08-10T14:00:00.000-1000"

I would expect it to equal:

"2012-08-10T14:00:00.000+1000"

If my understanding is not flawed, then this is the method that has the bug.

around line: 9805 (angular.js 1.0.1)

function timeZoneGetter(date) {
    var offset = date.getTimezoneOffset();
    return padNumber(offset / 60, 2) + padNumber(Math.abs(offset % 60), 2);
}
@pkozlowski-opensource
Copy link
Member

@benpriebe Seems like a bug to me too. Looking at http://www.w3.org/TR/NOTE-datetime it states:

Times are expressed in local time, together with a time zone offset in hours and minutes. A time zone offset of "+hh:mm" indicates that the date/time uses a local time zone which is "hh" hours and "mm" minutes ahead of UTC. A time zone offset of "-hh:mm" indicates that the date/time uses a local time zone which is "hh" hours and "mm" minutes behind UTC.

@pkozlowski-opensource
Copy link
Member

Definitively a duplicate of #1532

2 issues as far as I can tell:

  • +/- signs are flipped
  • + sign is never added

Going to close this one so we can focus on addressing #1532

latentflip added a commit to latentflip/angular.js that referenced this issue Jan 30, 2013
This commit fixes angular#1261 and angular#1532. This covers
two separate issues:

- Positive timezones were being formatted without
a leading `+` resulting in a formatting string
like: "HH:MM:ssZ" giving "12:13:141000" instead
of "12:13:14+1000". Fixed by checking if timezone
is > 0 and adding a leading "+".

- Timezone output signs were inverted.
mock.TzDate expects the timezone _offset_ as it's
first argument, _not_ the timezone. This means
that a mock.TzDate with a positive offset should
result in a date string with a negative timezone,
and vice-versa.
latentflip added a commit to latentflip/angular.js that referenced this issue Jan 30, 2013
This commit fixes angular#1261 and angular#1532. This covers
two separate issues:

- Positive timezones were being formatted without
a leading `+` resulting in a formatting string
like: "HH:MM:ssZ" giving "12:13:141000" instead
of "12:13:14+1000". Fixed by checking if timezone
is > 0 and adding a leading "+".

- Timezone output signs were inverted.
mock.TzDate expects the timezone _offset_ as it's
first argument, _not_ the timezone. This means
that a mock.TzDate with a positive offset should
result in a date string with a negative timezone,
and vice-versa.
latentflip added a commit to latentflip/angular.js that referenced this issue Feb 3, 2013
This commit fixes angular#1261 and angular#1532. This covers
two separate issues:

- Positive timezones were being formatted without
a leading `+` resulting in a formatting string
like: "HH:MM:ssZ" giving "12:13:141000" instead
of "12:13:14+1000". Fixed by checking if timezone
is > 0 and adding a leading "+".

- Timezone output signs were inverted.
mock.TzDate expects the timezone _offset_ as it's
first argument, _not_ the timezone. This means
that a mock.TzDate with a positive offset should
result in a date string with a negative timezone,
and vice-versa.
IgorMinar pushed a commit to IgorMinar/angular.js that referenced this issue Feb 7, 2013
This commit fixes angular#1261 and angular#1532. This covers
two separate issues:

- Positive timezones were being formatted without
a leading `+` resulting in a formatting string
like: "HH:MM:ssZ" giving "12:13:141000" instead
of "12:13:14+1000". Fixed by checking if timezone
is > 0 and adding a leading "+".

- Timezone output signs were inverted.
mock.TzDate expects the timezone _offset_ as it's
first argument, _not_ the timezone. This means
that a mock.TzDate with a positive offset should
result in a date string with a negative timezone,
and vice-versa.

Closes angular#1261, angular#1532
IgorMinar pushed a commit that referenced this issue Feb 7, 2013
This commit fixes #1261 and #1532. This covers
two separate issues:

- Positive timezones were being formatted without
a leading `+` resulting in a formatting string
like: "HH:MM:ssZ" giving "12:13:141000" instead
of "12:13:14+1000". Fixed by checking if timezone
is > 0 and adding a leading "+".

- Timezone output signs were inverted.
mock.TzDate expects the timezone _offset_ as it's
first argument, _not_ the timezone. This means
that a mock.TzDate with a positive offset should
result in a date string with a negative timezone,
and vice-versa.

Closes #1261, #1532
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants