Code Monkey home page Code Monkey logo

Comments (7)

z3bi avatar z3bi commented on June 22, 2024

@jd1378 is your use case that you want to be able to display both Maghrib and sunset?

from adhan-js.

jd1378 avatar jd1378 commented on June 22, 2024

yes

from adhan-js.

z3bi avatar z3bi commented on June 22, 2024

I don't think it makes sense to add it to nextPrayer since sunset isn't a prayer. Maghrib is the prayer time. We include sunrise since thats when the prayer time for Fajr specifically ends. It might make more sense to export SolarTime instead if you just want times of the sunset itself.

from adhan-js.

jd1378 avatar jd1378 commented on June 22, 2024

well its same usecase for maqrib in some places, it ends the prayer time for asr

from adhan-js.

jd1378 avatar jd1378 commented on June 22, 2024

But exporting SolarTime would be nice as well, but that would need exporting PolarCircleResolution ,TimeComponents and DateUtils to do the same thing as the lib is doing

from adhan-js.

jd1378 avatar jd1378 commented on June 22, 2024

I've already written a helper for myself, but I thought it would be nicer if the lib did it in the first place:

import {Coordinates, PolarCircleResolution} from 'adhan';

// @ts-ignore
import {isValidDate} from 'adhan/src/DateUtils';
// @ts-ignore
import {polarCircleResolvedValues} from 'adhan/src/PolarCircleResolution';
// @ts-ignore
import SolarTime from 'adhan/src/SolarTime';
// @ts-ignore
import TimeComponents from 'adhan/src/TimeComponents';

export function getSunset(
  date: Date,
  coordinates: Coordinates,
  polarCircleResolver = PolarCircleResolution.Unresolved,
): Date {
  let solarTime = new SolarTime(date, coordinates);
  let sunsetTime = new TimeComponents(solarTime.sunset).utcDate(
    date.getFullYear(),
    date.getMonth(),
    date.getDate(),
  );
  if (
    !isValidDate(sunsetTime) &&
    polarCircleResolver !== PolarCircleResolution.Unresolved
  ) {
    const resolved = polarCircleResolvedValues(
      polarCircleResolver,
      date,
      coordinates,
    );
    solarTime = resolved.solarTime;
    const dateComponents = [
      date.getFullYear(),
      date.getMonth(),
      date.getDate(),
    ];
    sunsetTime = new TimeComponents(solarTime.sunset).utcDate(
      ...dateComponents,
    );
  }

  return sunsetTime;
}

from adhan-js.

github-actions avatar github-actions commented on June 22, 2024

🎉 This issue has been resolved in version 4.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

from adhan-js.

Related Issues (20)

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.