So, I’m new to the land of Tidbyt and Starlark, and wanted to try my hand at creating a custom date/time app. I’d like to be able to get the day of the week and set it to a single unique character (U,M,T,W,H,F,S), but there doesn’t appear to be a DOW function in time.star.
Any recommendations?
I couldn’t find anything that did the single characters, best I found was the 3 letter abbreviations. A quick dictionary could help as one possible solution.
daymap = {
"Sun": "U"
"Mon": "M",
"Tue": "T",
"Wed": "W",
"Thu": "H",
"Fri": "F",
"Sat", "S"
}
foo = time.now().format("Mon")
print("Today is %s" % daymap[foo])
>> Today is M
1 Like
you could also just use foo[0]
if you just need the first letter. eliminating the dict altogether.
edit: put ticks around the code, also for one full line it would be time.now().format("Mon")[0]