Files
ComfyUI_frontend/src/utils/dateTimeUtil.ts
Benjamin Lu e42715086e Implement workflow progress panel (#6092)
Adds a workflow progress panel component underneath the
`actionbar-container`.

I suggest starting a review at the extraneous changes that were needed.
Including but not limited to:

- `get createTime()` in queueStore
- `promptIdToWorkflowId`, `initializingPromptIds`, and
`nodeProgressStatesByPrompt` in executionStore
- `create_time` handling in v2ToV1Adapter
- `pointer-events-auto` on ComfyActionbar.vue

The rest of the changes should be contained under
`QueueProgressOverlay.vue`, and has less of a blast radius in case
something goes wrong.

---------

Co-authored-by: pythongosssss <125205205+pythongosssss@users.noreply.github.com>
Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Jin Yi <jin12cc@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Alexander Brown <drjkl@comfy.org>
Co-authored-by: Johnpaul Chiwetelu <49923152+Myestery@users.noreply.github.com>
Co-authored-by: Christian Byrne <cbyrne@comfy.org>
Co-authored-by: Comfy Org PR Bot <snomiao+comfy-pr@gmail.com>
Co-authored-by: christian-byrne <72887196+christian-byrne@users.noreply.github.com>
2025-11-18 22:43:49 -08:00

78 lines
2.0 KiB
TypeScript

/**
* Return a local date key in YYYY-MM-DD format for grouping.
*
* @param ts Unix timestamp in milliseconds
* @returns Local date key string
*/
export const dateKey = (ts: number): string => {
const d = new Date(ts)
const y = d.getFullYear()
const m = String(d.getMonth() + 1).padStart(2, '0')
const day = String(d.getDate()).padStart(2, '0')
return `${y}-${m}-${day}`
}
/**
* Check if a timestamp is on the same local day as today.
*
* @param ts Unix timestamp in milliseconds
* @returns True if today
*/
export const isToday = (ts: number): boolean => {
const d = new Date(ts)
const now = new Date()
return (
d.getFullYear() === now.getFullYear() &&
d.getMonth() === now.getMonth() &&
d.getDate() === now.getDate()
)
}
/**
* Check if a timestamp corresponds to yesterday in local time.
*
* @param ts Unix timestamp in milliseconds
* @returns True if yesterday
*/
export const isYesterday = (ts: number): boolean => {
const d = new Date(ts)
const now = new Date()
const yest = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1)
return (
d.getFullYear() === yest.getFullYear() &&
d.getMonth() === yest.getMonth() &&
d.getDate() === yest.getDate()
)
}
/**
* Localized short month + day label, e.g. "Jan 2".
*
* @param ts Unix timestamp in milliseconds
* @param locale BCP-47 locale string
* @returns Localized month/day label
*/
export const formatShortMonthDay = (ts: number, locale: string): string => {
const d = new Date(ts)
return new Intl.DateTimeFormat(locale, {
month: 'short',
day: 'numeric'
}).format(d)
}
/**
* Localized clock time, e.g. "10:05:06" with locale defaults for 12/24 hour.
*
* @param ts Unix timestamp in milliseconds
* @param locale BCP-47 locale string
* @returns Localized time string
*/
export const formatClockTime = (ts: number, locale: string): string => {
const d = new Date(ts)
return new Intl.DateTimeFormat(locale, {
hour: 'numeric',
minute: '2-digit',
second: '2-digit'
}).format(d)
}