Skip to content

Commit

Permalink
Remove utils.displayTime in favour of FormattedTime component (matter…
Browse files Browse the repository at this point in the history
  • Loading branch information
niklabh authored and brewsterbhg committed Nov 11, 2019
1 parent e20c1df commit a52aa5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 38 deletions.
10 changes: 8 additions & 2 deletions components/admin_console/license_settings/license_settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import PropTypes from 'prop-types';
import React from 'react';
import {FormattedDate, FormattedMessage} from 'react-intl';
import {FormattedDate, FormattedTime, FormattedMessage} from 'react-intl';

import * as Utils from 'utils/utils.jsx';

Expand Down Expand Up @@ -99,7 +99,13 @@ export default class LicenseSettings extends React.Component {
let licenseType;
let licenseKey;

const issued = <React.Fragment><FormattedDate value={new Date(parseInt(license.IssuedAt, 10))}/>{' '}{Utils.displayTime(parseInt(license.IssuedAt, 10), true)}</React.Fragment>;
const issued = (
<React.Fragment>
<FormattedDate value={new Date(parseInt(license.IssuedAt, 10))}/>
{' '}
<FormattedTime value={new Date(parseInt(license.IssuedAt, 10))}/>
</React.Fragment>
);
const startsAt = <FormattedDate value={new Date(parseInt(license.StartsAt, 10))}/>;
const expiresAt = <FormattedDate value={new Date(parseInt(license.ExpiresAt, 10))}/>;

Expand Down
36 changes: 0 additions & 36 deletions utils/utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,42 +214,6 @@ export function getDateForUnixTicks(ticks) {
return new Date(ticks);
}

export function displayTime(ticks, utc) {
const d = new Date(ticks);
let hours;
let minutes;
let ampm = '';
let timezone = '';

if (utc) {
hours = d.getUTCHours();
minutes = d.getUTCMinutes();
timezone = ' UTC';
} else {
hours = d.getHours();
minutes = d.getMinutes();
}

if (minutes <= 9) {
minutes = '0' + minutes;
}

const useMilitaryTime = getBool(store.getState(), Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time');
if (!useMilitaryTime) {
ampm = ' AM';
if (hours >= 12) {
ampm = ' PM';
}

hours %= 12;
if (!hours) {
hours = '12';
}
}

return hours + ':' + minutes + ampm + timezone;
}

// returns Unix timestamp in milliseconds
export function getTimestamp() {
return Date.now();
Expand Down

0 comments on commit a52aa5e

Please sign in to comment.