Class PrayerTimes

Class representing prayer times calculation.

Constructors

  • Constructs a new instance of the PrayerTimes class.

    Parameters

    • method: string

      The calculation method to use for prayer times. If the provided method is not found, the default method 'MWL' will be used.

      Initializes the following properties:

      • timeNames: An object containing the names of the prayer times.
      • methods: An object containing different calculation methods and their parameters.
      • defaultParams: Default parameters for maghrib and midnight.
      • calcMethod: The calculation method to use, default is 'MWL'.
      • setting: An object containing settings for imsak, dhuhr, asr, and high latitude adjustments.
      • timeFormat: The format of the time, default is '24h'.
      • timeSuffixes: An array containing time suffixes 'am' and 'pm'.
      • invalidTime: A string representing an invalid time, default is '-----'.
      • numIterations: The number of iterations for calculation, default is 1.
      • offset: An object containing offsets for each prayer time, initialized to 0.
      • lat, lng, elv, timeZone, jDate: Geographical and time-related properties, initialized to 0.

      Sets the default parameters for each method if not already defined. Initializes the settings based on the selected calculation method. Initializes the time offsets for each prayer time to 0.

    Returns PrayerTimes

Methods

  • Adjusts the prayer time settings based on the provided parameters.

    Parameters

    • params: MethodParams

      An object containing the method parameters to adjust the settings.

    Returns void

  • Adjusts the Asr calculation method.

    Parameters

    • asrParam: "Standard" | "Hanafi"

      The Asr calculation method, either "Standard" or "Hanafi".

    Returns void

    Will throw an error if the asrParam is not "Standard" or "Hanafi".

  • Calculates prayer times for a given date, coordinates, and optional timezone and daylight saving time (DST) settings.

    Parameters

    • date: Date | number[]

      The date for which to calculate prayer times. Can be a Date object or an array of numbers [year, month, day].

    • coords: number[]

      The geographical coordinates [latitude, longitude, elevation] for the location.

    • Optionaltimezone: number | "auto"

      The timezone offset from UTC. Can be a number or 'auto' to automatically determine the timezone. Defaults to 'auto'.

    • Optionaldst: number | "auto"

      The daylight saving time setting. Can be a number (0 or 1) or 'auto' to automatically determine DST. Defaults to 'auto'.

    • Optionalformat: string

      The format for the prayer times. Defaults to the instance's timeFormat.

    Returns Times

    An object containing the calculated prayer times.

  • Sets the calculation method for prayer times.

    Parameters

    • method: string

      The name of the calculation method to set. This should be a key in the methods object.

    Returns void

    If the provided method exists in the methods object, this function will adjust the prayer times parameters according to the specified method and update the calcMethod property.