@@ -6,6 +6,7 @@ import cronstrue from "cronstrue"
6
6
import dayjs from "dayjs"
7
7
import duration from "dayjs/plugin/duration"
8
8
import relativeTime from "dayjs/plugin/relativeTime"
9
+ import utc from "dayjs/plugin/utc"
9
10
import { FC } from "react"
10
11
import { Link as RouterLink } from "react-router-dom"
11
12
import { Workspace } from "../../api/typesGenerated"
@@ -14,6 +15,7 @@ import { extractTimezone, stripTimezone } from "../../util/schedule"
14
15
import { isWorkspaceOn } from "../../util/workspace"
15
16
import { Stack } from "../Stack/Stack"
16
17
18
+ dayjs . extend ( utc )
17
19
dayjs . extend ( duration )
18
20
dayjs . extend ( relativeTime )
19
21
@@ -34,18 +36,21 @@ export const Language = {
34
36
}
35
37
} ,
36
38
autoStopDisplay : ( workspace : Workspace ) : string => {
37
- const deadline = workspace . latest_build . deadline
39
+ const deadline = dayjs ( workspace . latest_build . deadline ) . utc ( )
40
+ // a mannual shutdown has a deadline of '"0001-01-01T00:00:00Z"'
41
+ // SEE: #1834
42
+ const hasDeadline = deadline . year ( ) > 1
38
43
const ttl = workspace . ttl
39
44
40
- if ( isWorkspaceOn ( workspace ) ) {
45
+ if ( isWorkspaceOn ( workspace ) && hasDeadline ) {
41
46
// Workspace is on --> derive from latest_build.deadline. Note that the
42
47
// user may modify their workspace object (ttl) while the workspace is
43
48
// running and depending on system semantics, the deadline may still
44
49
// represent the previously defined ttl. Thus, we always derive from the
45
50
// deadline as the source of truth.
46
- const now = dayjs ( )
51
+ const now = dayjs ( ) . utc ( )
47
52
if ( now . isAfter ( deadline ) ) {
48
- return "Workspace is shutting down now "
53
+ return "Workspace is shutting down"
49
54
} else {
50
55
return now . to ( deadline )
51
56
}
0 commit comments