File size: 809 Bytes
e3278e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import * as React from "react";

interface TimeCellProps {
  utcTime: string;
}

const getLocalTime = (utcTime: string): string => {
  try {
    const date = new Date(utcTime);
    return date.toLocaleString('en-US', {
      year: 'numeric',
      month: '2-digit',
      day: '2-digit',
      hour: '2-digit',
      minute: '2-digit',
      second: '2-digit',
      hour12: true
    }).replace(',', '');
  } catch (e) {
    return "Error converting time";
  }
};

export const TimeCell: React.FC<TimeCellProps> = ({ utcTime }) => {
  return (
    <span style={{
      fontFamily: 'monospace',
      width: '180px',
      display: 'inline-block'
    }}>
      {getLocalTime(utcTime)}
    </span>
  );
};

export const getTimeZone = (): string => {
  return Intl.DateTimeFormat().resolvedOptions().timeZone;
};