calc

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2023 License: MIT Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

Functions

func DaysSinceSolstice

func DaysSinceSolstice(dayOfYear int, year int, latitude float64) int

func SeasonAdjustedEveningTwilight

func SeasonAdjustedEveningTwilight(latitude float64, day int, year int, sunset time.Time) time.Time

func SeasonAdjustedMorningTwilight

func SeasonAdjustedMorningTwilight(latitude float64, day int, year int, sunrise time.Time) time.Time

Types

type AsrJuristicMethod

type AsrJuristicMethod int64
const (
	SHAFI_HANBALI_MALIKI AsrJuristicMethod = iota

	HANAFI
)

type CalculationMethod

type CalculationMethod int64
const (
	OTHER CalculationMethod = iota
	// Muslim World League
	// Uses Fajr angle of 18 and an Isha angle of 17
	MUSLIM_WORLD_LEAGUE
	// Egyptian General Authority of Survey
	// Uses Fajr angle of 19.5 and an Isha angle of 17.5
	EGYPTIAN
	// University of Islamic Sciences, Karachi
	// Uses Fajr angle of 18 and an Isha angle of 18
	KARACHI
	// Umm al-Qura University, Makkah
	// Uses a Fajr angle of 18.5 and an Isha angle of 90. Note: You should add a +30 minute custom
	// adjustment of Isha during Ramadan.
	UMM_AL_QURA
	// The Gulf Region
	// Uses Fajr and Isha angles of 18.2 degrees.
	DUBAI
	// Moonsighting Committee
	// Uses a Fajr angle of 18 and an Isha angle of 18. Also uses seasonal adjustment values.
	MOON_SIGHTING_COMMITTEE
	// Referred to as the ISNA method
	// This method is included for completeness, but is not recommended.
	// Uses a Fajr angle of 15 and an Isha angle of 15.
	NORTH_AMERICA
	// Kuwait
	// Uses a Fajr angle of 18 and an Isha angle of 17.5
	KUWAIT
	// Qatar
	// Modified version of Umm al-Qura that uses a Fajr angle of 18.
	QATAR
	// Singapore
	// Uses a Fajr angle of 20 and an Isha angle of 18
	SINGAPORE
	// UOIF
	// Uses a Fajr angle of 12 and an Isha angle of 12
	UOIF
)

type CalculationParameters

type CalculationParameters struct {
	//  The method used to do the calculation
	Method CalculationMethod

	// The angle of the sun used to calculate fajr
	FajrAngle float64

	// The angle of the sun used to calculate isha
	IshaAngle float64

	// Minutes after Maghrib (if set, the time for Isha will be Maghrib plus IshaInterval)
	IshaInterval int

	// The juristic method used to calculate Asr
	Madhab AsrJuristicMethod

	// Rules for placing bounds on Fajr and Isha for high latitude areas
	HighLatitudeRule HighLatitudeRule

	// Used to optionally add or subtract a set amount of time from each prayer time
	Adjustments PrayerAdjustments

	// Used for method adjustments
	MethodAdjustments PrayerAdjustments
}

func GetMethodParameters

func GetMethodParameters(method CalculationMethod) *CalculationParameters

func (*CalculationParameters) NightPortions

func (c *CalculationParameters) NightPortions() (*NightPortions, error)

type CalculationParametersBuilder

type CalculationParametersBuilder struct {
	//  The method used to do the calculation
	Method CalculationMethod

	// The angle of the sun used to calculate fajr
	FajrAngle float64

	// The angle of the sun used to calculate isha
	IshaAngle float64

	// Minutes after Maghrib (if set, the time for Isha will be Maghrib plus IshaInterval)
	IshaInterval int

	// The juristic method used to calculate Asr
	Madhab AsrJuristicMethod

	// Rules for placing bounds on Fajr and Isha for high latitude areas
	HighLatitudeRule HighLatitudeRule

	// Used to optionally add or subtract a set amount of time from each prayer time
	Adjustments PrayerAdjustments

	// Used for method adjustments
	MethodAdjustments PrayerAdjustments
}

func NewCalculationParametersBuilder

func NewCalculationParametersBuilder() *CalculationParametersBuilder

func (*CalculationParametersBuilder) Build

func (*CalculationParametersBuilder) SetAdjustments

func (*CalculationParametersBuilder) SetFajrAngle

func (*CalculationParametersBuilder) SetHighLatitudeRule

func (cpb *CalculationParametersBuilder) SetHighLatitudeRule(highLatitudeRule HighLatitudeRule) *CalculationParametersBuilder

func (*CalculationParametersBuilder) SetIshaAngle

func (*CalculationParametersBuilder) SetIshaInterval

func (cpb *CalculationParametersBuilder) SetIshaInterval(ishaInterval int) *CalculationParametersBuilder

func (*CalculationParametersBuilder) SetMadhab

func (*CalculationParametersBuilder) SetMethod

func (*CalculationParametersBuilder) SetMethodAdjustments

func (cpb *CalculationParametersBuilder) SetMethodAdjustments(methodAdjustments PrayerAdjustments) *CalculationParametersBuilder

type HighLatitudeRule

type HighLatitudeRule int64
const (
	NO_HIGH_LATITUDE_RULE HighLatitudeRule = iota

	// Fajr will never be earlier than the middle of the night, and Isha will never be later than
	// the middle of the night.
	MIDDLE_OF_THE_NIGHT

	// Fajr will never be earlier than the beginning of the last seventh of the night, and Isha will
	// never be later than the end of the first seventh of the night.
	SEVENTH_OF_THE_NIGHT

	// Similar to SEVENTH_OF_THE_NIGHT, but instead of 1/7th, the fraction of the night used
	// is fajrAngle / 60 and ishaAngle/60.
	TWILIGHT_ANGLE
)

type NightPortions

type NightPortions struct {
	Fajr float64
	Isha float64
}

func NewNightPortions

func NewNightPortions(fajr float64, isha float64) (*NightPortions, error)

type Prayer

type Prayer int64
const (
	NO_PRAYER Prayer = iota

	FAJR

	SUNRISE

	DHUHR

	ASR

	MAGHRIB

	ISHA
)

type PrayerAdjustments

type PrayerAdjustments struct {
	FajrAdj    int
	SunriseAdj int
	DhuhrAdj   int
	AsrAdj     int
	MaghribAdj int
	IshaAdj    int
}

type PrayerTimes

type PrayerTimes struct {
	Fajr              time.Time
	Sunrise           time.Time
	Dhuhr             time.Time
	Asr               time.Time
	Maghrib           time.Time
	Isha              time.Time
	Coords            *util.Coordinates
	DateComponent     *data.DateComponents
	CalculationParams *CalculationParameters
}

func NewPrayerTimes

func NewPrayerTimes(coords *util.Coordinates, date *data.DateComponents, params *CalculationParameters) (*PrayerTimes, error)

func (*PrayerTimes) CurrentPrayer

func (p *PrayerTimes) CurrentPrayer(t time.Time) Prayer

func (*PrayerTimes) CurrentPrayerNow

func (p *PrayerTimes) CurrentPrayerNow() Prayer

func (*PrayerTimes) NextPrayer

func (p *PrayerTimes) NextPrayer(t time.Time) Prayer

func (*PrayerTimes) NextPrayerNow

func (p *PrayerTimes) NextPrayerNow() Prayer

func (*PrayerTimes) SetTimeZone

func (p *PrayerTimes) SetTimeZone(tzone string) error

func (*PrayerTimes) TimeForPrayer

func (p *PrayerTimes) TimeForPrayer(prayer Prayer) time.Time

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL