Permalink
Browse files

fix #64

  • Loading branch information...
1 parent 96d2214 commit c7bbb60522e9253bd44837a9426defbc8e0ebd98 @longlho longlho committed Feb 14, 2013
Showing with 22 additions and 6 deletions.
  1. +2 −1 spec/test-utils.js
  2. +15 −0 spec/tz.default.spec.js
  3. +5 −5 src/date.js
View
@@ -31,6 +31,7 @@ var fs = require('fs');
};
timezoneJS.timezone.loadingScheme = opts.loadingScheme;
+ timezoneJS.timezone.defaultZoneFile = opts.defaultZoneFile;
if (opts.loadingScheme !== timezoneJS.timezone.loadingSchemes.MANUAL_LOAD) {
//Set up again
timezoneJS.timezone.zoneFileBasePath = 'lib/tz';
@@ -48,7 +49,7 @@ var fs = require('fs');
}
}
return init(require('../src/date'), options);
- }
+ };
TestUtils.parseISO = function (timestring) {
var pat = '^(?:([+-]?[0-9]{4,})(?:-([0-9]{2})(?:-([0-9]{2}))?)?)?' +
View
@@ -0,0 +1,15 @@
+var TestUtils = require('./test-utils')
+ , parseISO = TestUtils.parseISO
+ , date = require('../src/date')
+ , timezoneJS = TestUtils.getTimezoneJS({
+ defaultZoneFile: 'asia'
+ });
+describe('TimezoneJS', function () {
+ it('should preload everything correctly', function () {
+ expect(timezoneJS.timezone.loadingScheme).toEqual(date.timezone.loadingSchemes.LAZY_LOAD);
+ expect(timezoneJS.timezone.loadedZones.asia).toBe(true);
+ sampleTz = timezoneJS.timezone.getTzInfo(new Date(), 'Asia/Bangkok');
+ expect(sampleTz).toBeDefined();
+ expect(sampleTz.tzAbbr).toEqual('ICT');
+ });
+});
View
@@ -79,7 +79,7 @@
if (el === this[i]) return i;
}
return -1;
- }
+ };
}
// Format a number to the length = digits. For ex:
@@ -248,7 +248,7 @@
}
this._tzInfo = res;
this._useCache = true;
- return res
+ return res;
},
getUTCDateProxy: function () {
var dt = new Date(this._timeProxy);
@@ -802,7 +802,7 @@
return res;
}
- this.zoneFileBasePath;
+ this.zoneFileBasePath = null;
this.zoneFiles = ['africa', 'antarctica', 'asia', 'australasia', 'backward', 'etcetera', 'europe', 'northamerica', 'pacificnew', 'southamerica'];
this.loadingSchemes = {
PRELOAD_ALL: 'preloadAll',
@@ -816,9 +816,9 @@
this.init = function (o) {
var opts = { async: true }
- , def = this.defaultZoneFile = this.loadingScheme === this.loadingSchemes.PRELOAD_ALL
+ , def = this.loadingScheme === this.loadingSchemes.PRELOAD_ALL
? this.zoneFiles
- : 'northamerica'
+ : (this.defaultZoneFile || 'northamerica')
, done = 0
, callbackFn;
//Override default with any passed-in opts

0 comments on commit c7bbb60

Please sign in to comment.