{"size": 1217, "ext": "js", "max_stars_repo_path": "utils/timezone_utils.js", "max_stars_repo_name": "monkeydbobo/mattermost-redux", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "utils/timezone_utils.js", "max_issues_repo_name": "monkeydbobo/mattermost-redux", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "utils/timezone_utils.js", "max_forks_repo_name": "monkeydbobo/mattermost-redux", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.7321428571, "max_line_length": 67, "alphanum_fraction": 0.70336894}
/*:: import type {UserTimezone} from 'types/users';*/
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getUserCurrentTimezone = getUserCurrentTimezone;
exports.getTimezoneRegion = getTimezoneRegion;

require("core-js/modules/es6.regexp.replace");

require("core-js/modules/es6.regexp.split");

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// @flow
function getUserCurrentTimezone(userTimezone
/*: UserTimezone*/
)
/*: ?string*/
{
  if (!userTimezone) {
    return null;
  }

  var useAutomaticTimezone = userTimezone.useAutomaticTimezone,
      automaticTimezone = userTimezone.automaticTimezone,
      manualTimezone = userTimezone.manualTimezone;
  var useAutomatic = useAutomaticTimezone;

  if (typeof useAutomaticTimezone === 'string') {
    useAutomatic = useAutomaticTimezone === 'true';
  }

  if (useAutomatic) {
    return automaticTimezone;
  }

  return manualTimezone;
}

function getTimezoneRegion(timezone
/*: string*/
)
/*: string*/
{
  if (timezone) {
    var split = timezone.split('/');

    if (split.length > 1) {
      return split.pop().replace(/_/g, ' ');
    }
  }

  return timezone;
}