Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
svk31 committed May 25, 2018
2 parents e2f1433 + 87d45f6 commit d385d34
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions app/components/Exchange/tradingViewClasses.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ class DataFeed {
}

const supportedTimeZones = [
"Africa/Johannesburg",
"America/Argentina/Buenos_Aires",
"America/Bogota",
"America/Caracas",
Expand Down Expand Up @@ -381,24 +380,25 @@ const supportedTimeZones = [

function getTVTimezone() {
const current = moment.tz.guess();
const defaultZone = "Europe/London";

let isSupported = supportedTimeZones.indexOf(current) !== -1;
if (isSupported) return current;
else {
/* Try to find a matching timezone from the limited list supported by TradingView */
const time = moment().toISOString();
const defaultZone = "Europe/London";
const actual = moment.tz(time, current).format();
let continent = current.split("/")[0];
let possibleZones = supportedTimeZones.filter(
z => z.indexOf(continent) !== -1
);
if (!possibleZones.length) return defaultZone; // default
for (var i = 0; i < possibleZones.length; i++) {
let zoneTime = moment.tz(time, possibleZones[i]);
for (var i = 0; i < supportedTimeZones.length; i++) {
let zoneTime = moment.tz(time, supportedTimeZones[i]);
if (zoneTime.format() === actual) {
if (__DEV__)
console.log(
`Found a match for ${current} timezone, using ${
supportedTimeZones[i]
}`
);
// Found a match, return that zone
return possibleZones[i];
return supportedTimeZones[i];
}
}
}
Expand Down

0 comments on commit d385d34

Please sign in to comment.