Skip to content

Commit

Permalink
fix: Render timestamp of protobuf in UTC (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
honnix authored Sep 25, 2020
1 parent c29c0ee commit 37604a0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/Literals/Scalar/PrimitiveValue.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';

import { formatDate, protobufDurationToHMS } from 'common/formatters';
import { formatDateUTC, protobufDurationToHMS } from 'common/formatters';
import { timestampToDate } from 'common/utils';
import { Primitive } from 'models';

Expand All @@ -10,7 +10,7 @@ function primitiveToString(primitive: Primitive): string {
case 'boolean':
return !!primitive.boolean ? 'true' : 'false';
case 'datetime':
return formatDate(timestampToDate(primitive.datetime!));
return formatDateUTC(timestampToDate(primitive.datetime!));
case 'duration':
return protobufDurationToHMS(primitive.duration!);
default:
Expand Down
25 changes: 25 additions & 0 deletions src/components/Literals/Scalar/test/PrimitiveValue.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { render } from '@testing-library/react';
import * as React from 'react';

import { Primitive } from 'models';
import { PrimitiveValue } from '../PrimitiveValue';

import { long } from 'test/utils';

describe('PrimitiveValue', () => {
it('renders datetime', () => {
const primitive: Primitive = {
value: 'datetime',
datetime: {
seconds: long(3600),
nanos: 0
},
boolean: false,
integer: long(0),
floatValue: 0,
stringValue: ''
};
const { getByText } = render(<PrimitiveValue primitive={primitive} />);
expect(getByText('1/1/1970 1:00:00 AM UTC')).toBeInTheDocument();
});
});

0 comments on commit 37604a0

Please sign in to comment.