Giter VIP home page Giter VIP logo

go-prayer's People

Contributors

radhifadlillah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

go-prayer's Issues

Crash: panic: Cannot create a Decimal from NaN

Error log:

panic: Cannot create a Decimal from NaN

goroutine 25 [running]:
github.com/shopspring/decimal.newFromFloat(0x7ff8000000000001, 0x7ff8000000000001, 0xbd1bf0, 0xbff0626d4dcc0f2e, 0x7ff8000000000001)
    /home/onodera/wrk/pkg/mod/github.com/shopspring/[email protected]/decimal.go:210 +0x443
github.com/shopspring/decimal.NewFromFloat(0x7ff8000000000001, 0x7ff8000000000001, 0xbff0626d4dcc0f2e)
    /home/onodera/wrk/pkg/mod/github.com/shopspring/[email protected]/decimal.go:186 +0x92
github.com/RadhiFadlillah/go-prayer/internal/trigonometry.Acos(0xc0010fa980, 0xc0fffffff0, 0xc0010fa8c0, 0xffffffe0)
    /home/onodera/wrk/pkg/mod/github.com/!radhi!fadlillah/[email protected]/internal/trigonometry/trigonometry.go:35 +0x57
github.com/RadhiFadlillah/go-prayer/internal/prayer.TimeCalculator.getHourAngle(0x4035000000000000, 0xc0010c01c0, 0xfffffffc, 0xc0010c01e0, 0xfffffffc, 0xc0010c0160, 0x0, 0xc0010c0180, 0x0, 0xc0010c01a0, ...)
    /home/onodera/wrk/pkg/mod/github.com/!radhi!fadlillah/[email protected]/internal/prayer/calculator.go:137 +0x1da
github.com/RadhiFadlillah/go-prayer/internal/prayer.TimeCalculator.GetFajrTime(0x4035000000000000, 0xc0010c01c0, 0xfffffffc, 0xc0010c01e0, 0xfffffffc, 0xc0010c0160, 0x0, 0xc0010c0180, 0x0, 0xc0010c01a0, ...)
    /home/onodera/wrk/pkg/mod/github.com/!radhi!fadlillah/[email protected]/internal/prayer/calculator.go:59 +0x86
github.com/RadhiFadlillah/go-prayer.GetTimes(0xbfaa3a7d46adac71, 0x1f358fb3, 0xc16440, 0x404a1058793dd97f, 0x4016aca57a786c22, 0x4035000000000000, 0x0, 0x0, 0x1, 0x0, ...)
    /home/onodera/wrk/pkg/mod/github.com/!radhi!fadlillah/[email protected]/calculator.go:74 +0x2bb
main.(*Bar).initPopups.func1()
    /home/onodera/wrk/src/github.com/onodera-punpun/melonbar/popups.go:40 +0x1fd
main.(*Bar).drawPopup(0xc000ce0460, 0x7cf0bf, 0x5, 0x4, 0x74c760)
    /home/onodera/wrk/src/github.com/onodera-punpun/melonbar/popup.go:75 +0x334
main.(*Bar).initBlocks.func17(0xc0005f2322, 0xc000116910)
    /home/onodera/wrk/src/github.com/onodera-punpun/melonbar/blocks.go:293 +0x3f
created by main.(*Bar).drawBlocks.func1
    /home/onodera/wrk/src/github.com/onodera-punpun/melonbar/block.go:103 +0x23a

I have a feeling this is because something rounds to zero or something, which makes the decimal package return a panic.

Code that crashes (for me):

			// Get the prayer times.
			ptl, _ := prayer.GetTimes(time.Now(), prayer.Config{
				Latitude:          52.1277,
				Longitude:         5.6686,
				Elevation:         21,
				CalculationMethod: prayer.MWL,
				AsrJuristicMethod: prayer.Hanafi,
				PreciseToSeconds:  false,
			})

Slightly changing the Latitude to 51 for example fixes the crash, also the crash didn't happen last week.

time is different with kemenag official prayer times

hey @RadhiFadlillah thanks a lot for your great effort for this library, may Allah bless you.

i want use this package as source of our application prayer times, but when it compared to kemenag official prayer times the result was different. here is my code without any corrections config:

// Calculate prayer schedule in Bekasi for 2023.
asiaJakarta, _ := time.LoadLocation("Asia/Jakarta")
bekasiSchedules, _ := prayer.Calculate(prayer.Config{
          Latitude:           -6.241586,
	  Longitude:          106.992416,
          Timezone:           asiaJakarta,
          TwilightConvention: prayer.Kemenag(),
          AsrConvention:      prayer.Shafii,
          PreciseToSeconds:   true,
          Corrections:        prayer.ScheduleCorrections{},
}, 2023)

the result was

========== 2023-11-30 ==========
fajr:  2023-11-30 04:02:46 +0700 WIB
dhuhr:  2023-11-30 11:40:28 +0700 WIB
asr:  2023-11-30 15:05:46 +0700 WIB
maghrib:  2023-11-30 17:54:07 +0700 WIB
isha:  2023-11-30 19:09:23 +0700 WIB
====================================

wether in kemenag the result was like this
Capture-2023-11-30-211443

the data shows

  • fajr = minus 3 minutes
  • dhuhr = minus 4 minutes
  • asr = minus 3 minutes
  • maghrib = minus 3 minutes
  • isya = minus 3 minutes

my question is, is this expected and we need to fill the corrections config?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.