fixed types

master
Claire 1 year ago
parent
commit
1bf6e48056
  1. 8
      Home.md

8
Home.md

@ -316,10 +316,10 @@ I can't take credit for figuring out the math on this. I was lucky to find [this
Here's the overview: Here's the overview:
1. Use the lunar cycle constant `29.53058770576` and calculate its duration in seconds as `lunarSecs`. 1. Use the lunar cycle constant `29.53058770576` and calculate its duration in seconds as `lunarDays`.
2. Convert date of first full moon in 2000 (January 6 at 18:14 UTC) to unix timestamp as `lunarSecs`. 2. Convert date of first full moon in 2000 (January 6 at 18:14 UTC) to unix timestamp as `lunarSecs`.
3. Calculate `totalSecs` which is the time (in seconds) between the user date and the moment of the first new moon in 2000 3. Calculate `totalSecs` which is the time (in seconds) between the user date and `lunarDays`.
4. If the result is positive, it's valid, so calculate the modulus (remainder) of `totalSecs` divided by `lunarSecs` , to know the amount of seconds that have passed in the current cycle as `currSecs`. 4. If the result is positive, it's valid, so calculate the modulus (remainder) of `totalSecs` divided by `lunarSecs`, which will return the total seconds that have passed in the current cycle as `currSecs`.
5. Divide `currSecs` by `lunarSecs` to find the current position in the lunar cycle as `currentFrac`. 5. Divide `currSecs` by `lunarSecs` to find the current position in the lunar cycle as `currentFrac`.
6. Multiply `currFrac` by `lunarDays` to get this value in days as `currDays`. 6. Multiply `currFrac` by `lunarDays` to get this value in days as `currDays`.
7. Find the correct moon phase based on the value of `currDays`. 7. Find the correct moon phase based on the value of `currDays`.
@ -330,7 +330,7 @@ This is all just basic arithmetic, so let's get into the Swift implementation.
Since we're going to want this app to stay updated automatically, the math is going into a function named `updateIcon()`. This is the `key` we're going to pass to the `buildMenu()` function we already built. Since we're going to want this app to stay updated automatically, the math is going into a function named `updateIcon()`. This is the `key` we're going to pass to the `buildMenu()` function we already built.
First, we're going to get the curren system date and time with [Date](https://developer.apple.com/documentation/foundation/date). This is always in UTC. First, we're going to get the current system date and time with [Date](https://developer.apple.com/documentation/foundation/date). This is always in UTC.
```swift ```swift
// update menu bar icon // update menu bar icon

Loading…
Cancel
Save