File tree 2 files changed +14
-4
lines changed
2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ func workspaceListRowFromWorkspace(now time.Time, workspace codersdk.Workspace)
46
46
if ! ptr .NilOrEmpty (workspace .AutostartSchedule ) {
47
47
if sched , err := cron .Weekly (* workspace .AutostartSchedule ); err == nil {
48
48
autostartDisplay = fmt .Sprintf ("%s %s (%s)" , sched .Time (), sched .DaysOfWeek (), sched .Location ())
49
- nextStartDisplay = relative (sched .Next ( now ). Sub (now ))
49
+ nextStartDisplay = timeDisplay (sched .Next (now ))
50
50
}
51
51
}
52
52
@@ -55,9 +55,8 @@ func workspaceListRowFromWorkspace(now time.Time, workspace codersdk.Workspace)
55
55
if ! ptr .NilOrZero (workspace .TTLMillis ) {
56
56
dur := time .Duration (* workspace .TTLMillis ) * time .Millisecond
57
57
autostopDisplay = durationDisplay (dur )
58
- if ! workspace .LatestBuild .Deadline .IsZero () && workspace .LatestBuild .Deadline .Time .After (now ) && status == "Running" {
59
- remaining := time .Until (workspace .LatestBuild .Deadline .Time )
60
- nextStopDisplay = fmt .Sprintf ("%s (%s)" , autostopDisplay , relative (remaining ))
58
+ if ! workspace .LatestBuild .Deadline .IsZero () && workspace .LatestBuild .Transition == codersdk .WorkspaceTransitionStart {
59
+ nextStopDisplay = timeDisplay (workspace .LatestBuild .Deadline .Time )
61
60
}
62
61
}
63
62
Original file line number Diff line number Diff line change @@ -62,6 +62,17 @@ func durationDisplay(d time.Duration) string {
62
62
return sign + durationDisplay
63
63
}
64
64
65
+ // timeDisplay formats a time in the local timezone
66
+ // in RFC3339 format.
67
+ func timeDisplay (t time.Time ) string {
68
+ localTz , err := tz .TimezoneIANA ()
69
+ if err != nil {
70
+ localTz = time .UTC
71
+ }
72
+
73
+ return t .In (localTz ).Format (time .RFC3339 )
74
+ }
75
+
65
76
// relative relativizes a duration with the prefix "ago" or "in"
66
77
func relative (d time.Duration ) string {
67
78
if d > 0 {
You can’t perform that action at this time.
0 commit comments