Movatterモバイル変換


[0]ホーム

URL:


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

fix: show explicit schedule stop time#2171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
greyscaled merged 2 commits intomainfromvapurrmaid/gh-2141/explicit-stop-time
Jun 8, 2022
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletionssite/src/components/WorkspaceSchedule/WorkspaceSchedule.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,8 +4,10 @@ import Typography from "@material-ui/core/Typography"
import ScheduleIcon from "@material-ui/icons/Schedule"
import cronstrue from "cronstrue"
import dayjs from "dayjs"
import advancedFormat from "dayjs/plugin/advancedFormat"
import duration from "dayjs/plugin/duration"
import relativeTime from "dayjs/plugin/relativeTime"
import timezone from "dayjs/plugin/timezone"
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Review:

Both are needed to manipulate time in the user's timezone and display timezone information (specifically where you see.format("z")

import utc from "dayjs/plugin/utc"
import { FC } from "react"
import { Link as RouterLink } from "react-router-dom"
Expand All@@ -15,27 +17,32 @@ import { extractTimezone, stripTimezone } from "../../util/schedule"
import { isWorkspaceOn } from "../../util/workspace"
import { Stack } from "../Stack/Stack"

dayjs.extend(advancedFormat)
dayjs.extend(utc)
dayjs.extend(duration)
dayjs.extend(relativeTime)
dayjs.extend(timezone)

export const Language = {
autoStartDisplay: (schedule: string | undefined): string => {
if (schedule) {
return cronstrue.toString(stripTimezone(schedule), { throwExceptionOnParseError: false })
} else {
return "Manual"
}
return "Manual"
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Review:

Just meeting the FE code convention of using explicitelse here.

},
autoStartLabel: (schedule: string | undefined): string => {
const prefix = "Start"
const timezone = schedule ? extractTimezone(schedule) : dayjs.tz.guess()

if (schedule) {
return `${prefix} (${extractTimezone(schedule)})`
return `${prefix} (${dayjs().tz(timezone).format("z")})`
} else {
return prefix
}
},
autoStopDisplay: (workspace: Workspace): string => {
const schedule = workspace.autostart_schedule
const deadline = dayjs(workspace.latest_build.deadline).utc()
// a mannual shutdown has a deadline of '"0001-01-01T00:00:00Z"'
// SEE: #1834
Expand All@@ -52,7 +59,8 @@ export const Language = {
if (now.isAfter(deadline)) {
return "Workspace is shutting down"
} else {
return now.to(deadline)
const timezone = schedule ? extractTimezone(schedule) : dayjs.tz.guess()
return deadline.tz(timezone).format("HH:mm A")
}
} else if (!ttl || ttl < 1) {
// If the workspace is not on, and the ttl is 0 or undefined, then the
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp