forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for global timezones. Closes elastic#1600
- Loading branch information
Showing
8 changed files
with
76 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,47 @@ | ||
describe('Date Format', function () { | ||
var fieldFormats; | ||
var expect = require('expect.js'); | ||
var ngMock = require('ngMock'); | ||
var moment = require('moment-timezone'); | ||
var fieldFormats; | ||
var settings; | ||
var convert; | ||
var $scope; | ||
var off; | ||
|
||
beforeEach(ngMock.module('kibana')); | ||
beforeEach(ngMock.inject(function (Private) { | ||
beforeEach(ngMock.inject(function (Private, config, $rootScope) { | ||
$scope = $rootScope; | ||
settings = config; | ||
|
||
fieldFormats = Private(require('ui/registry/field_formats')); | ||
var DateFormat = fieldFormats.getType('date'); | ||
var date = new DateFormat(); | ||
|
||
convert = date.convert.bind(date); | ||
})); | ||
|
||
it('decoding an undefined or null date should return an empty string', function () { | ||
var DateFormat = fieldFormats.getType('date'); | ||
var date = new DateFormat({ | ||
pattern: 'dd-MM-yyyy' | ||
}); | ||
expect(date.convert(null)).to.be('-'); | ||
expect(date.convert(undefined)).to.be('-'); | ||
expect(convert(null)).to.be('-'); | ||
expect(convert(undefined)).to.be('-'); | ||
}); | ||
|
||
it('should clear the memoization cache after changing the date', function () { | ||
function setDefaultTimezone() { | ||
moment.tz.setDefault(settings.get('dateFormat:tz')); | ||
} | ||
var time = 1445027693942; | ||
|
||
off = $scope.$on('change:config.dateFormat:tz', setDefaultTimezone); | ||
|
||
settings.set('dateFormat:tz', 'America/Chicago'); | ||
$scope.$digest(); | ||
var chicagoTime = convert(time); | ||
|
||
settings.set('dateFormat:tz', 'America/Phoenix'); | ||
$scope.$digest(); | ||
var phoenixTime = convert(time); | ||
|
||
expect(chicagoTime).not.to.equal(phoenixTime); | ||
off(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
var moment = module.exports = require('../node_modules/moment-timezone/moment-timezone'); | ||
moment.tz.load(require('../node_modules/moment-timezone/data/packed/latest.json')); |