How to derive day of week?

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

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 ="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"Mon")[0]

I’ve run into this to. Just sent in Add day_of_week to humanize module by dinosaursrarr · Pull Request #401 · tidbyt/pixlet · GitHub to add a day of week function.