Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phase and fraction never become zero, How can I determine which is full moon and new moon ? #154

Open
indrajitv opened this issue Jul 4, 2021 · 1 comment

Comments

@indrajitv
Copy link

indrajitv commented Jul 4, 2021

 let sunCalc = SwiftySuncalc()
    var todayDate = Date()
    let localDateFormatter: DateFormatter = {
        let formatter = DateFormatter()
        formatter.timeZone = .current
        formatter.dateFormat = "MMM d yyyy"
        return formatter
    }()
    func getMoonIllumination() {
        
        for i in 1...360 {
            let illumination = sunCalc.getMoonIllumination(date: self.todayDate)
            if let phase = illumination["phase"],
               let angle = illumination["angle"],
               let fraction = illumination["fraction"] {
                print("phase \(phase) | angle \(angle) | fraction \(fraction) | day \(self.localDateFormatter.string(from: todayDate))")
            }
            todayDate = Date().addingTimeInterval(TimeInterval(i*24*60*60))
        }
    }

phase 0.8208798434751472 | angle 1.2205030548890408 | fraction 0.2846125787100251 | day Jul 4 2021
phase 0.8208830053193001 | angle 1.2205077774514717 | fraction 0.28460361441866144 | day Jul 5 2021
phase 0.8208832163668929 | angle 1.2205080926822833 | fraction 0.28460301607084565 | day Jul 6 2021
phase 0.8208833719187054 | angle 1.220508325022601 | fraction 0.2846025750611427 | day Jul 7 2021
phase 0.8208834934215778 | angle 1.2205085065059846 | fraction 0.2846022305847748 | day Jul 8 2021
phase 0.8208836735706424 | angle 1.2205087755872015 | fraction 0.284601719839094 | day Jul 9 2021
phase 0.8208838119284052 | angle 1.2205089822469763 | fraction 0.2846013275772954 | day Jul 10 2021
phase 0.8208845985176147 | angle 1.2205101571537502 | fraction 0.284599097500256 | day Jul 11 2021
phase 0.8208845985176147 | angle 1.2205101571537502 | fraction 0.284599097500256 | day Jul 12 2021
phase 0.8208845985176147 | angle 1.2205101571537502 | fraction 0.284599097500256 | day Jul 13 2021
phase 0.8208845985176147 | angle 1.2205101571537502 | fraction 0.284599097500256 | day Jul 14 2021
phase 0.8208845985176147 | angle 1.2205101571537502 | fraction 0.284599097500256 | day Jul 15 2021
phase 0.8208845985176147 | angle 1.2205101571537502 | fraction 0.284599097500256 | day Jul 16 2021
phase 0.8208845985176147 | angle 1.2205101571537502 | fraction 0.284599097500256 | day Jul 17 2021
phase 0.8208845985176147 | angle 1.2205101571537502 | fraction 0.284599097500256 | day Jul 18 2021
phase 0.8208845985176147 | angle 1.2205101571537502 | fraction 0.284599097500256 | day Jul 19 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Jul 20 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Jul 21 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Jul 22 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Jul 23 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Jul 24 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Jul 25 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Jul 26 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Jul 27 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Jul 28 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Jul 29 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Jul 30 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Jul 31 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Aug 1 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Aug 2 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Aug 3 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Aug 4 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Aug 5 2021
phase 0.8208845988708059 | angle 1.2205101576813164 | fraction 0.28459909649891696 | day Aug 6 2021

Moon phase value should be interpreted like this:

Phase Name
0 New Moon
  Waxing Crescent
0.25 First Quarter
  Waxing Gibbous
0.5 Full Moon
  Waning Gibbous
0.75 Last Quarter
  Waning Crescent
@indrajitv indrajitv changed the title Phase and fraction never becomes zero, How can I determine which is full moon and new moon ? Phase and fraction never become zero, How can I determine which is full moon and new moon ? Jul 4, 2021
@Artoria2e5
Copy link

Wrong repository; go to https://github.com/cristiangonzales/SwiftySuncalc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants