| Name | Description | Parameters | Return | Expression |
|---|---|---|---|---|
| Whether the current year is a leap year (366 days) | - | 0 (NO) 1 (YES) |
([YEAR] % 4 == 0) | |
| 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)) | |
| 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)) |
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:
- If the year % 4 equals to 0, do step 2. Otherwise, not a leap year.
- If the year % 100 equals to 0, do step 3. Otherwise, is a leap year.
- 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.
I created this expression a long time ago. I don't remember the logic behind it. Sorry!
You can find the explanation for this expression in the video P003 - Week calendar (at 02:20).
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!
| Coin | Address |
|---|---|
| Bitcoin | bc1q36tlwv6a4p0rlrtt088atwu7yjce63we38pn8v |