Color My Weekends (or MyString)

I’d like to make weekend days in Captain’s Log stand out from weekdays by using red for the color of the note name.

Reading this previous thread, I had the impression I could set $Color="red", but if I try to show $Color in Displayed Attributes, it doesn’t come up in the list. This is what I’m trying in the prototype Month edict:

if($Created.month == date("today").month)
{
$MyDate="today";
$MyString=$MyDate.format("W, L");
if $MyString.contains("S")
{
$Color="red";
create($MyString);
}
else
{
create($MyString);
}
if($Created.month != date("today").month) $EdictDisabled;

What am I missing?

P.S. I’m hoping that .contains is case sensitive, otherwise Wednesday and Thursday will be the color of my face. ChatGPT tells me I could use this regex to get Saturday or Sunday because they’re the only days that begin with “S”

\bS\w*\b

But I’m hoping for the simple case first.

It also just occurs to me that I’m going to need an “else” statement in there, but please help me out with the color first. (Think I fixed that. Also, this color thing is addressed in aTbRef, but it’s not working for me.)

Simpler would be to use Date.weekday(). Values are 1 through 7, so >6 (Sat, Sun) is the weekend.

So:

if($MyDate.weekday>5){
   $Color = "red"; // it's a weekend day!
}

[edit] you can always add an else so the note takes its (prototype’s) default:

if($MyDate.weekday>5){
   $Color = "red"; // it's a weekend day!
} else {
   $Color =; // it's a weekday
};
1 Like

Simpler, ok. But does my code not work? Because it’s not changing the color of today’s container.

And $Color doesn’t appear in the list when you enter “Color” in Displayed Attributes. Color2 appears, but no single word “Color”.

  1. Color is an attribute, and can indeed be added to the Displayed Attributes list. Try it in a new document, just to check.

  2. Is a rule, edict, or OnVisit action setting the Displayed Attributes? If so, that could be changing the displayed attributes after you set them.

  3. You only need $MyDate.format(“W”), which gives you the weekday as a string.

  4. Another test for Sunday would be MyDate.weekday==7. This is slightly more robust, because an Italian user would see that $MyDate.format("W") was Domenica, which doesn’t start with S.

  5. As you have seen — i saw the edit as I was typing this! — you had omitted the {…braces…} surrounding the if clause.

  6. Do you want to turn this note red? Or the newly-created note? If so, you’d want something like:

var:string newNote=create($MyString);
$Color(newNote)="red";
1 Like

This is turning the Month red.

if($Created.month == date("today").month)
{
$MyDate="today";
$MyString=$MyDate.format("W, L");
if($MyDate.weekday>5){
   $Color = "red"; // it's a weekend day!
} else {
   $Color =; // it's a weekday
}
create($MyString);

if($Created.month != date("today").month) $EdictDisabled;

This is in a copy of the log to experiment on.

@eastgate, I was just going to take two screenshots to illustrate what I was seeing, that “Color” did not appear. As soon as I took the screenshot, I saw it. Amazing. Kept looking and looking and wondering what the heck was going on. Gotta get my eyes examined.

I’m using the Long form because I’m including the date in the name of the note. “Friday, March 14, 2025” It would be open in its own tab. Won’t confuse one Friday with another.

Take a look at this (untested)

var:string newNote=create($MyString);
if($MyDate.weekday>5){
   $Color(newNote) = "red"; // it's a weekend day!
} else {
   $Color(newNote) =; // it's a weekday
}

You want to create the new note first. Then, if today its Sunday, you want to set its color.

1 Like

Okay, this is trippy.

Click on the Displayed Attributes selector grid.

Enter “color” → lower case “c”

Do you see “Color” in the drop-down list? I don’t.

Enter “Color” → upper case “C”

There it is!

As near as I can tell, every other attribute is case insensitive when trying to enter one and summoning the list.

That works. Much appreciated. I had the impression to you had to set the color first, then create the note.

Nor should you expect too! Why? Because spell-checking/auto-complete matching, IIRC, works off three or more characters. So, type ‘c’ and get no match but type ‘col’ and ‘Color’ shows as a match. Why so? Starting at >=3 characters massively reduces the possible number of matches. It’s a pragmatic choice to keep things responsive. Some apps start matching of 3, some a higher number. IIRC, the latter is more likely in mobile phone context (think: less powerful CPU).

This also explains why apps and OS sometimes mark (with red dotted underline) a word as incorrect but offer no correction. More often than not, it is because the error is in the first few letters. It’s not a dictionary exact match nor do the first three characters stem a dictionary match.