Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 21ff8dc

Browse files
committed
Merge branch '335-ui-date-format' into 'master'
fix(ui): support both date formats in UI: custom and RFC3339 (#335) Closes #335 See merge request postgres-ai/database-lab!510
2 parents 1953123 + 9d0d9a7 commit 21ff8dc

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

‎ui/packages/shared/types/api/entities/clone.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*--------------------------------------------------------------------------
66
*/
77

8-
import { parseISO9075Date } from '@postgres.ai/shared/utils/date'
8+
import { parseDate } from '@postgres.ai/shared/utils/date'
99
import {
1010
SnapshotDto,
1111
formatSnapshotDto,
@@ -35,7 +35,7 @@ export type CloneDto = {
3535
export const formatCloneDto = (dto: CloneDto) => ({
3636
...dto,
3737
createdAt: dto.createdAt,
38-
createdAtDate: parseISO9075Date(dto.createdAt),
38+
createdAtDate: parseDate(dto.createdAt),
3939
snapshot: dto.snapshot ? formatSnapshotDto(dto.snapshot) : null,
4040
})
4141

‎ui/packages/shared/types/api/entities/snapshot.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { parseISO9075Date } from '@postgres.ai/shared/utils/date'
1+
import { parseDate } from '@postgres.ai/shared/utils/date'
22

33
export type SnapshotDto = {
44
createdAt: string
@@ -11,8 +11,8 @@ export type SnapshotDto = {
1111

1212
export const formatSnapshotDto = (dto: SnapshotDto) => ({
1313
...dto,
14-
createdAtDate: parseISO9075Date(dto.createdAt),
15-
dataStateAtDate: parseISO9075Date(dto.dataStateAt)
14+
createdAtDate: parseDate(dto.createdAt),
15+
dataStateAtDate: parseDate(dto.dataStateAt)
1616
})
1717

1818
export type Snapshot = ReturnType<typeof formatSnapshotDto>

‎ui/packages/shared/utils/date.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ import {
2121
formatDistanceToNowStrict,
2222
} from 'date-fns'
2323

24-
export const parseISO9075Date = (dateStr: string) =>
25-
parse(dateStr.replace('UTC', 'Z'), 'yyyy-MM-dd HH:mm:ss X', new Date())
24+
// parseDate parses date of both format: '2006年01月02日 15:04:05 UTC' and `2006年01月02日T15:04:05Z` (RFC3339).
25+
export const parseDate = (dateStr: string) =>
26+
parse(dateStr.replace(' UTC', 'Z').replace('T', ' '), 'yyyy-MM-dd HH:mm:ssX', new Date())
2627

2728
// UTCf - UTC formatted, but not actually UTC.
2829
// date-fns using this approach because browser don't have an opportunity to switch single date

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /