mde / timezone-js

DEPRECATED: Timezone-enabled JavaScript Date object. Uses Olson zoneinfo files for timezone data.
824 stars 183 forks source link

buggy loadingSchemes logic #64

Closed jacobg closed 11 years ago

jacobg commented 11 years ago

Looks like the beginning of the init function should be:

def = this.loadingScheme === this.loadingSchemes.PRELOAD_ALL
          ? this.zoneFiles
          : this.loadingScheme === this.loadingSchemes.LAZY_LOAD
            ? (typeof this.defaultZoneFile === 'array'  || typeof this.defaultZoneFile === 'string' ? this.defaultZoneFile : 'northamerica')
            : def = [] // MANUAL_LOAD

instead of:

def = this.loadingScheme === this.loadingSchemes.PRELOAD_ALL
          ? this.zoneFiles
          : (this.defaultZoneFile ? this.defaultZoneFile : 'northamerica')
longlho commented 11 years ago

what was the issue exactly? Can u provide some example snippets?

jacobg commented 11 years ago

Without the above fix, the following code loads northamerica and not asia:

        // create shorter aliases for timezoneJS in global namespace
        tzjs = timezoneJS;
        tzjs.tz = tzjs.timezone;

        tzjs.tz.zoneFileBasePath = '/static/lib/tz';
        tzjs.tz.defaultZoneFile = 'asia';
        tzjs.tz.init();
mde commented 11 years ago

Nice.