Add a clock format with live seconds (#7586)
* Add a clock format with live seconds Right-clicking the clock now reaches "Thursday 09:39:23" and its AM/PM twin, and the widget's SystemClock ticks once a second only while a format that prints seconds is showing — every other format keeps the minute precision it had, so nobody pays for a repaint a second to read a label that changes once a minute. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * Read an unterminated literal in a clock format as text Qt reads an opening quote with no closing one as a literal running to the end of the format, so "HH:mm 'sec" prints "09:39 sec" and never a second count — but the seconds test stripped only balanced quotes, saw the s, and put the widget on a per-second tick for a label that changes once a minute. The wiring assertions went the other way: each passed while the feature was broken, so hard-coding showsSeconds to false, dropping the label's onDateChanged, or commenting the precision line out and leaving the text behind all shipped green. Comments now come out of the source before it is matched, and both halves of the tick are asserted. Co-Authored-By: Codex XHigh <noreply@openai.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> Co-authored-by: Codex XHigh <noreply@openai.com>
This commit is contained in:
co-authored by
Claude Opus 5
Codex XHigh
parent
688d7df5d2
commit
d3d9bea1ee
@@ -21,6 +21,8 @@ var WEEKDAY_NAMES = ["sunday", "monday", "tuesday", "wednesday", "thursday", "fr
|
||||
var CLOCK_FORMATS = [
|
||||
"dddd HH:mm",
|
||||
"dddd h:mm AP",
|
||||
"dddd HH:mm:ss",
|
||||
"dddd h:mm:ss AP",
|
||||
"HH:mm",
|
||||
"h:mm AP",
|
||||
"ddd d MMM HH:mm",
|
||||
@@ -39,6 +41,15 @@ var VERTICAL_CLOCK_FORMATS = [
|
||||
"HH\nmm"
|
||||
]
|
||||
|
||||
// Whether a format prints seconds, so the widget can tick once a second only
|
||||
// for the formats that show them. Quoted literals go first: the s in a 'Sat'
|
||||
// is text rather than a token, and an opening quote with no closing one runs
|
||||
// to the end of the format the way Qt reads it.
|
||||
function clockNeedsSeconds(format) {
|
||||
var text = String(format === undefined || format === null ? "" : format)
|
||||
return /s/.test(text.replace(/'[^']*'?/g, ""))
|
||||
}
|
||||
|
||||
function clockFormats(vertical) {
|
||||
return vertical ? VERTICAL_CLOCK_FORMATS.slice() : CLOCK_FORMATS.slice()
|
||||
}
|
||||
@@ -289,6 +300,7 @@ if (typeof module !== "undefined") {
|
||||
monthGrid: monthGrid,
|
||||
stepMonth: stepMonth,
|
||||
clockFormats: clockFormats,
|
||||
clockNeedsSeconds: clockNeedsSeconds,
|
||||
clockFormatRing: clockFormatRing,
|
||||
nextClockFormat: nextClockFormat,
|
||||
isoWeekLiteral: isoWeekLiteral
|
||||
|
||||
Reference in New Issue
Block a user