Skip to content

tenoeight/wfs-expressions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

List of expressions that can be used on Watch Face Studio

        Name                   Description                   Parameters                 Return           Expression                                

Is a leap year

Whether the current year is a leap year (366 days) - 0 (NO)
1 (YES)
([YEAR] % 4 == 0)

Day of week for day 1

Returns the day of week for the first day (day 1) of the current month - 1 (Sunday)
2 (Monday)
3 (Tuesday)
4 (Wednesday)
5 (Thursday)
6 (Friday)
7 (Saturday)
([DAY_WEEK]==(([DAY_1_31]%7)==0?6:(([DAY_1_31]%7)-1))?7:([DAY_WEEK]-(([DAY_1_31]%7)==0?6:(([DAY_1_31]%7)-1)))+(([DAY_WEEK]<(([DAY_1_31]%7)==0?6:(([DAY_1_31]%7)-1)))*7))

Number of days from previous month

Returns the total number of days the previous month has - 28
29
30
31
(([MON]==3)?((([YEAR]%4)==0)?29:28):(((([MON]==5)+([MON]==7)+([MON]==10)+([MON]==12))>0)?30:31))

Explanations

Is a leap year

A regular year has 365 days. However the Earth takes 365.24 days to revolve once about the sun. For this reason every 4 years an extra day is added to improve the calendar precision. Any year that is evenly divided by 4 is considered a leap year. Therefore to check if the year is leap or not, we just need to check if the mod of the year is equal to 0, using tags the formula would be:

([YEAR] % 4 == 0)

Some years however are evenly divisible by 4, but are not leap year, for example: 1700, 1800, 1900, 2100, 2200, 2300, 2500 and 2600 are not leap year. To fix this issue a couple of steps needs to be checked:

  1. If the year % 4 equals to 0, do step 2. Otherwise, not a leap year.
  2. If the year % 100 equals to 0, do step 3. Otherwise, is a leap year.
  3. If the year % 400 equals to 0, is a leap year. Otherwise, not a leap year.

This can also be converted to an expression, like this:

(([YEAR] % 4 == 0) ? (([YEAR] % 100 == 0) ? (([YEAR] % 400 == 0) ? 1 : 0) : 1) : 0)

Even though the second expression is the complete version, the first will fail only on the years I mentioned above. Considering that the next error will be in the year of 2100, I don't think it is necessary to use the complete version of the equation; it will only consume more battery.

Day of week for day one

I created this expression a long time ago. I don't remember the logic behind it. Sorry!

Number of days from previous month

You can find the explanation for this expression in the video P003 - Week calendar (at 02:20).

Donations

In case you would like to support me, you can make a donation using the options bellow 😊. Donations ARE NOT required to consume/use any content!

ko-fi

Coin Address
Bitcoin bc1q36tlwv6a4p0rlrtt088atwu7yjce63we38pn8v

Contributors