Waybar icon indicating copy to clipboard operation
Waybar copied to clipboard

Clock: Ability to use `%s` format specifier to get Unix Timestamp

Open Sofviic opened this issue 1 year ago • 1 comments

I cannot seem to find a way to format the clock such that it shows the time in unix timestamps.

I expected {:%s} to work but didn't, and couldn't find a way to do it in the docs.

Ideally I want the following to work:

    "clock": {
	"timezones": [
		     "Etc/GMT-2",
		     "Etc/UTC",
		     "Europe/Berlin",
		     "Etc/GMT-3"
	],
        "tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>\n\n<big>{tz_list}</big>",
        "format": "{:%Y-%m-%d\t[W%U,D%j]\n%H:%M:%S\t(UTC%:::z,%Z)}",
	"format-alt": "{:%s}",
	"interval": 1
    },

PS. Is there also a way to to have the offset from UTC (%z) but without the minutes? (I wrote it as %:::z above)

Sofviic avatar Jul 14 '24 17:07 Sofviic

The clock module uses the chrono format specification which specifies several chrono_type formats, but unfortunately %s is not included, at least according to this document. Maybe there is a workaround for this but I don't know.

nyrzeff avatar Jul 22 '24 22:07 nyrzeff