Discuss Scratch
- Discussion Forums
- » Suggestions
- » New Extension Suggestion: "Lunar Calendar"
- fdreerf
-
Scratcher
1000+ posts
New Extension Suggestion: "Lunar Calendar"
What if someone did this:Again, how do you determine which holidays to put in the dropdown to be both inclusive to all cultures and only feature major holidays to keep the list concise? It seems like an impossible dilemma, so I can't say I support this.when green flag clicked
ask [Enter a holiday and I'll calculate the month.] and wait
say (date [month v] of (answer) :: sensing)
- Scratch---Cat
-
Scratcher
1000+ posts
New Extension Suggestion: "Lunar Calendar"
Bump
Today is February 30th :: boolean operator
- fdreerf
-
Scratcher
1000+ posts
New Extension Suggestion: "Lunar Calendar"
Wait, couldn't you create a workaround with some magic math formula, using 29.53059 (a synodic month) to get the lunar phases forever?
- scramaso
-
Scratcher
500+ posts
New Extension Suggestion: "Lunar Calendar"
Wait, couldn't you create a workaround with some magic math formula, using 29.53059 (a synodic month) to get the lunar phases forever?exactly
- fdreerf
-
Scratcher
1000+ posts
New Extension Suggestion: "Lunar Calendar"
I made one.
I subtracted 6 because that's the closest new moon to January 1st was on the 6th.
((((days since 2000) - (6)) mod (29.53059)) / (29.53059))This gives the lunar phase as a percentage, where 0 is a new moon, 0.5 is a full moon and it cycles forever.
I subtracted 6 because that's the closest new moon to January 1st was on the 6th.
- scramaso
-
Scratcher
500+ posts
New Extension Suggestion: "Lunar Calendar"
I made one.So, new moon is 0, full is 0.5 and 1 is new too?((((days since 2000) - (6)) mod (29.53059)) / (29.53059))This gives the lunar phase as a percentage, where 0 is a new moon, 0.5 is a full moon and it cycles forever.
I subtracted 6 because that's the closest new moon to January 1st was on the 6th.
- chrdagos
-
Scratcher
500+ posts
New Extension Suggestion: "Lunar Calendar"
Wait, couldn't you create a workaround with some magic math formula, using 29.53059 (a synodic month) to get the lunar phases forever?nope.
the moon is drifting away from the earth, which means the moon's orbit will take longer and longer.
- scramaso
-
Scratcher
500+ posts
New Extension Suggestion: "Lunar Calendar"
it happends tha same with earth, but we dont have 24.23124381750934715910357975013405715345151345 hours long daysWait, couldn't you create a workaround with some magic math formula, using 29.53059 (a synodic month) to get the lunar phases forever?nope.
the moon is drifting away from the earth, which means the moon's orbit will take longer and longer.
- fdreerf
-
Scratcher
1000+ posts
New Extension Suggestion: "Lunar Calendar"
Fun fact: the moon drifts at 3.8 cm on average per year. In 500 years, it would've moved only 19 meters. Spoiler alert: everyone alive today will be dead.Wait, couldn't you create a workaround with some magic math formula, using 29.53059 (a synodic month) to get the lunar phases forever?nope.
the moon is drifting away from the earth, which means the moon's orbit will take longer and longer.
So, new moon is 0, full is 0.5 and 1 is new too?The mod function will never reach 1, it will just be 0.
Last edited by fdreerf (March 23, 2020 19:27:28)
- scramaso
-
Scratcher
500+ posts
New Extension Suggestion: "Lunar Calendar"
exactlyFun fact: the moon drifts at 3.8 cm on average per year. In 500 years, it would've moved only 19 meters. Spoiler alert: everyone alive today will be dead.Wait, couldn't you create a workaround with some magic math formula, using 29.53059 (a synodic month) to get the lunar phases forever?nope.
the moon is drifting away from the earth, which means the moon's orbit will take longer and longer.
- scramaso
-
Scratcher
500+ posts
New Extension Suggestion: "Lunar Calendar"
I'm making an example project about this.
- chrdagos
-
Scratcher
500+ posts
New Extension Suggestion: "Lunar Calendar"
the moon drifts at 3.8 cm on average per yearthat is why a workaround won't be exact forever.
- imfh
-
Scratcher
1000+ posts
New Extension Suggestion: "Lunar Calendar"
So, you could use that to simplify the code below to and find Easter? If so, I am surprised I haven’t seen a formula which has already uses it. I don’t think that magic number is accurate enough to get Easter reliably.exactlyFun fact: the moon drifts at 3.8 cm on average per year. In 500 years, it would've moved only 19 meters. Spoiler alert: everyone alive today will be dead.Wait, couldn't you create a workaround with some magic math formula, using 29.53059 (a synodic month) to get the lunar phases forever?nope.
the moon is drifting away from the earth, which means the moon's orbit will take longer and longer.
private static DateTime Easter(int year) { int a = year%19; int b = year/100; int c = (b - (b/4) - ((8*b + 13)/25) + (19*a) + 15)%30; int d = c - (c/28)*(1 - (c/28)*(29/(c + 1))*((21 - a)/11)); int e = d - ((year + (year/4) + d + 2 - b + (b/4))%7); int month = 3 + ((e + 40)/44); int day = e + 28 - (31*(month/4)); return new DateTime(year, month , day); }
- scramaso
-
Scratcher
500+ posts
New Extension Suggestion: "Lunar Calendar"
now convert that into scratchSo, you could use that to simplify the code below to and find Easter? If so, I am surprised I haven’t seen a formula which has already uses it. I don’t think that magic number is accurate enough to get Easter reliably.exactlyFun fact: the moon drifts at 3.8 cm on average per year. In 500 years, it would've moved only 19 meters. Spoiler alert: everyone alive today will be dead.Wait, couldn't you create a workaround with some magic math formula, using 29.53059 (a synodic month) to get the lunar phases forever?nope.
the moon is drifting away from the earth, which means the moon's orbit will take longer and longer.Sourceprivate static DateTime Easter(int year) { int a = year%19; int b = year/100; int c = (b - (b/4) - ((8*b + 13)/25) + (19*a) + 15)%30; int d = c - (c/28)*(1 - (c/28)*(29/(c + 1))*((21 - a)/11)); int e = d - ((year + (year/4) + d + 2 - b + (b/4))%7); int month = 3 + ((e + 40)/44); int day = e + 28 - (31*(month/4)); return new DateTime(year, month , day); }
- fdreerf
-
Scratcher
1000+ posts
New Extension Suggestion: "Lunar Calendar"
So, all we need to do is calculate the first Sunday after the first full moon on or after 21 March. (Thanks Wikipedia!) I can't say I can use the code imfh gave us because I can't understand C# and it looks like even those who do are confused, so I'm making my own thing. As of now, the hardest part seems to be when to detect the day of the week.
- imfh
-
Scratcher
1000+ posts
New Extension Suggestion: "Lunar Calendar"
So, all we need to do is calculate the first Sunday after the first full moon on or after 21 March. (Thanks Wikipedia!) I can't say I can use the code imfh gave us because I can't understand C# and it looks like even those who do are confused, so I'm making my own thing. As of now, the hardest part seems to be when to detect the day of the week.You can detect the day of week with the current [ v] block.
Last edited by imfh (March 23, 2020 21:58:13)
- chrdagos
-
Scratcher
500+ posts
New Extension Suggestion: "Lunar Calendar"
set A to current year mod 19private static DateTime Easter(int year) { int a = year%19; int b = year/100; int c = (b - (b/4) - ((8*b + 13)/25) + (19*a) + 15)%30; int d = c - (c/28)*(1 - (c/28)*(29/(c + 1))*((21 - a)/11)); int e = d - ((year + (year/4) + d + 2 - b + (b/4))%7); int month = 3 + ((e + 40)/44); int day = e + 28 - (31*(month/4)); return new DateTime(year, month , day); }
set B to current year/100
set C to B - (B/4) - ((8*B + 13)/25) + (19*A) + 15) mod 30
set D to C - (C/28) * (1 - (C/28) * (29/(C + 1)) * ((21 - A)/11))
set E to D - ((current year + (current year/4) + D + 2 - B + (B/4)) mod 7
set MONTH to 3 + ((E + 40)/44)
set DAY to E + 28 - (31 * (MONTH/4))
set OOF to join current year, MONTH, DAY
i found it easy converting C# into a more readable form.
Last edited by chrdagos (March 23, 2020 22:58:13)
- fdreerf
-
Scratcher
1000+ posts
New Extension Suggestion: "Lunar Calendar"
Yes, but what I'm doing spits out the the nth day of the year Easter falls on. It's hard to figure out the day of the week with only “99” and “2020” to work with.So, all we need to do is calculate the first Sunday after the first full moon on or after 21 March. (Thanks Wikipedia!) I can't say I can use the code imfh gave us because I can't understand C# and it looks like even those who do are confused, so I'm making my own thing. As of now, the hardest part seems to be when to detect the day of the week.You can detect the day of week with the current [ v] block.
Also, I tried the C# way and it didn't work.
- imfh
-
Scratcher
1000+ posts
New Extension Suggestion: "Lunar Calendar"
Since it was done in C# integer division, you have to floor all of the calculations. There is also an error in your calculation of E; you forgot to have D - … at the beginning. Here it is working: https://www.desmos.com/calculator/af3uaw76i9 Btw. it looks pretty neat if you delete the year variable.Yes, but what I'm doing spits out the the nth day of the year Easter falls on. It's hard to figure out the day of the week with only “99” and “2020” to work with.So, all we need to do is calculate the first Sunday after the first full moon on or after 21 March. (Thanks Wikipedia!) I can't say I can use the code imfh gave us because I can't understand C# and it looks like even those who do are confused, so I'm making my own thing. As of now, the hardest part seems to be when to detect the day of the week.You can detect the day of week with the current [ v] block.
Also, I tried the C# way and it didn't work.
- Discussion Forums
- » Suggestions
-
» New Extension Suggestion: "Lunar Calendar"





