Comments (4)
This is because @dmfilipenko didn't take daylight savings into account, it seems. It looks like this is a snapshot of time zones at some arbitrary point in time.
from timezones.json.
Oh man, my job has this file committed to the codebase, I'm so glad I found this github project because I was chasing my tail trying to figure out the issue I was seeing in my app's UI.
Finally, I discovered that EST has this same issue, which ultimately led me here.
If you must continue using this file in your project (we are for now), I think it is cleaner to parse the offset out of the text
property rather than rely on the numerical offset
property provided in the JSON data.
I am using this code snippet to map the timezones in this JSON by their UTC offset according to their text property.
Note that these UTC offsets are mapped by minutes, not hours.
import {groupBy} from 'lodash';
const UTCOffsetRegex: RegExp = /\(UTC(.*?)\)/;
const timezoneJson = [ ... ];
interface Timezone {
value: string;
abbr: string;
offset: number;
isdst: boolean;
text: string;
utc?: string[];
}
static get tzByOffsetMins(): {[key: number]: Timezone[]} {
const tzOffsetMap: {[key: number]: Timezone[]} = groupBy(timezoneJson, (timezone: Timezone): number => {
const offset: string = UTCOffsetRegex.exec(timezone.text)[1];
const [hours, mins]: string[] = offset.split(':');
const hoursAsMins: number = Math.abs(Number(hours) * 60);
const offsetMultiplier: number = hours.startsWith('-') ? -1 : 1;
const totalMins: number = hoursAsMins + Number(mins);
const offsetInt: number = totalMins * offsetMultiplier;
return offsetInt;
});
return tzOffsetMap;
}
from timezones.json.
Yep! I thought I was going crazy.... spent 3 days figuring out why I was always off by one hour when I had a use case between calculating delta between Pacific Standard Time and Central Standard Time... He has the offset for CST set to -5 but it's supposed to be -6 and PST is correct at -8...
from timezones.json.
I've notices several of these differences, where the text
and offset
values differ. For example these two:
{
value: 'Central Standard Time',
abbr: 'CDT',
offset: -5,
isdst: true,
text: '(UTC-06:00) Central Time (US & Canada)',
utc: [ ... ],
},
{
value: 'Eastern Standard Time',
abbr: 'EDT',
offset: -4,
isdst: true,
text: '(UTC-05:00) Eastern Time (US & Canada)',
utc: [ ... ],
},
Anyone got any insight into this?
Edit: I made some cross checking and created this gist if anyone is interested (https://gist.github.com/adrielTosi/7a08cc60dc3f00e68733bb9b65b7adeb). I don't claim it's 100% correct, but the values to offset
and text
are the same.
from timezones.json.
Related Issues (20)
- Request to keep old IANA equivalents HOT 1
- Issues after Daylight Saving time change exp New Zealand Daylight Time HOT 2
- Typo for Nepal Standard Time HOT 1
- Duplicate timezones HOT 3
- Greenwich Mean Time to GMT Standard Time HOT 1
- Data is incorrect (does not account for DST) HOT 1
- Data is incorrect for Kaliningrad HOT 1
- Question: What is the plan for non canonical values HOT 3
- duplicate abbr HOT 4
- Duplicate values HOT 1
- Russian data is out of date HOT 1
- Timezone parameter does not change the output of the api HOT 1
- Bug: UTC-05 is by definition a -5h offset. HOT 1
- Canberra is GMT+11, not GMT+10 ?
- Central Daylight Time is missing?
- Time Zones in Alaska, United States (AKDT vs AKST)
- America/Mexico_City should be GMT-6 now
- Cairo standard time should be GMT+3.
- Include AEDT: Australian Eastern Daylight Time
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from timezones.json.