jstimezoneDetect not detecting the right timezones

Im using jsTimezoneDetect and the time for the library always seem to be random. For example if I refresh a page, it will be a completely random time. Could be off by 12hrs, 5hrs, 8hrs, etc. And its not just the hr that is wrong, the minute time is as well. So thats why I call it a complelely random time. Like it seems like it is not based on any timezone, but just a random time generated by the system on each refresh. So I have been going through the docs for jsTimezoneDetect to see if there are any solutions but I couldnt find anything for it. Please see my code below. Thanks!

import jstz from 'jstimezonedetect';


if (pair && exchange) {
      if (this.chartIsReady === this.CHART_STATES.NOT_LOADED ||
        prevProps.theme.palette.type !== theme.palette.type ||
        prevProps.isFeatureEnabled.CHARTS !== isFeatureEnabled.CHARTS) {
        this.chartIsReady = this.CHART_STATES.LOADING;
        this.datafeed = new PokeUdfDatafeed(`${PUBLIC_API_ROOT}/charts/exchange/${exchange}`, exchange, pair);
        this.chartSaveAdapter = new PokeChartSaveAdapter(exchange, this.updateExchangeAndPair);
        this.chartOpenOrdersHandler = null;
        this.chartTradeHistoryHandler = null;
        this.initTVChart(exchange, account, pair, openOrdersData, theme, isFeatureEnabled.CHARTS);
        return;
      }


initTVChart = (exchange, account, pair, openOrdersData, theme, isChartsEnabled) => {
    const { defaultChartTimeframe } = this.props;
    const widgetOptions = {
      symbol: pair,
      interval: defaultChartTimeframe,
      timezone: jstz.determine().name(),
      container_id: 'tvChartContainer',
      locale: 'en',
      datafeed: this.datafeed,
      autosize: true,
      library_path: '/platform/static/trading_view/charting_library/',
      client_id: 'platform-ui',
      user_id: 'public_user_id',
      // drawings_access: { type: 'black', tools: [{ name: 'Regression Trend' }] },
      disabled_features: [
        'use_localstorage_for_settings',
        'display_market_status',
        'header_symbol_search',
        'symbol_search_hot_key',
        'header_interval_dialog_button',
        'compare_symbol',
        'header_compare',
        'header_undo_redo',
        'header_screenshot',
        'border_around_the_chart',
        'go_to_date',
        'hide_left_toolbar_by_default'
      ],
      enabled_features: ['side_toolbar_in_fullscreen_mode', 'keep_left_toolbar_visible_on_small_screens', 'left_toolbar'],
      side_toolbar_in_fullscreen_mode: true,
      save_load_adapter: this.chartSaveAdapter,
      overrides: {
        editorFontsList: ['Source Sans', 'Verdana', 'Courier New', 'Times New Roman', 'Arial'],
        'mainSeriesProperties.candleStyle.upColor': '#9FC950',
        'mainSeriesProperties.candleStyle.downColor': '#D35847',
        'mainSeriesProperties.candleStyle.drawBorder': false,
        'mainSeriesProperties.candleStyle.wickUpColor': 'rgba( 159, 201, 80, 1)',
        'mainSeriesProperties.candleStyle.wickDownColor': 'rgba( 211, 88, 77, 1)',
      },
      studies_overrides: indicatorStyleOverrides,
      theme: 'Light',
      // load_last_chart: true, // disabling because it breaks things
    };

Source: Ask Javascript Questions

LEAVE A COMMENT