feat(filter): support conversion to timezone other than UTC #10858

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@shahata
Contributor
shahata commented Jan 24, 2015

No description provided.

@googlebot googlebot added the cla: yes label Jan 24, 2015
@shahata shahata feat(filter): support conversion to timezone other than UTC
2968e50
@shahata
Contributor
shahata commented Jan 24, 2015

If this is something we want, I can do it also for ng-model-options, but let's get this in first

@petebacondarwin petebacondarwin commented on the diff Jan 26, 2015
test/ng/filter/filtersSpec.js
@@ -457,5 +457,14 @@ describe('filters', function() {
expect(date(new Date(2003, 8, 10, 3, 2, 4), 'yyyy-MM-dd HH-mm-ss')).toEqual('2003-09-10 03-02-04');
expect(date(new Date(Date.UTC(2003, 8, 10, 3, 2, 4)), 'yyyy-MM-dd HH-mm-ss', 'UTC')).toEqual('2003-09-10 03-02-04');
});
+
+ it('should support conversion to any timezone', function() {
+ expect(date(new Date(Date.UTC(2003, 8, 10, 3, 2, 4)), 'yyyy-MM-dd HH-mm-ssZ', 'GMT+0500')).toEqual('2003-09-10 08-02-04+0500');
+ });
+
+ it('should fallback to default timezone in case an unknown timezone was passed', function() {
@petebacondarwin
petebacondarwin Jan 26, 2015 Member

Question: Fallback to local or to UTC?

@petebacondarwin
petebacondarwin Jan 26, 2015 Member

I guess the current behaviour (before this PR) is to fallback to local time.

@shahata
shahata Jan 26, 2015 Contributor

I currently fallback to local tz, but I can change it if you think UTC is preferred.

@shahata
shahata Jan 26, 2015 Contributor

hmmm, yes, throwing is also a viable option. we could also have the filter output something that indicates a problem. not sure. I don't think we have any other filters that can fail, I'll look into it.

@petebacondarwin
petebacondarwin Jan 27, 2015 Member

Let's go with what you have - it is a reasonable default and it is what happens now.

@petebacondarwin
Member

LGTM - let's merge and then look at the date input controls

@shahata shahata closed this in c6d8512 Feb 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment