Skip to content

Commit

Permalink
timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashraf-Ali-aa committed Oct 31, 2023
1 parent b344e25 commit 94deb94
Show file tree
Hide file tree
Showing 17 changed files with 746 additions and 752 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
},
"dependencies": {
"adhan-extended": "^6.1.0",
"luxon": "^3.3.0"
"luxon": "^3.3.0",
"@photostructure/tz-lookup": "^8.0.0"
}
}
184 changes: 0 additions & 184 deletions src/adhan/calculate.test.ts

This file was deleted.

136 changes: 0 additions & 136 deletions src/adhan/calculate.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/adhan/calculation-methods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ describe('calculatePrayerTimes', () => {
const result = calculatePrayerTimes(date, settings);
const formated = result?.format({
use24HourFormat: false,
timezone: city.timezone,
});

expect(result?.dateTime.zoneName).toEqual(city.timezone);
Expand Down
9 changes: 9 additions & 0 deletions src/adhan/calculation-methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import {
PrayerTimesOptions,
CalculationMethodKey,
AsrCalculationType,
ICoords,
} from './types';
import { DateTime } from 'luxon';
import { PrayerAndSunnahTimes } from './prayer-and-sunnah-times';
import { timeZoneLookup } from '../utils/timezone';

export const CalculationMethods: Record<
CalculationMethodKey,
Expand Down Expand Up @@ -355,6 +357,7 @@ function getPrayerTimesOptionsFromSettings(
midnightAdjustment: midnightAdjustment ?? 0,
};

setTimeZone(prayerTimeOptions, location);
setRounding(prayerTimeOptions, roundingMethod);
setAdjustments(prayerTimeOptions, settings);
setOverrides(prayerTimeOptions, settings);
Expand All @@ -366,6 +369,12 @@ function getPrayerTimesOptionsFromSettings(
return prayerTimeOptions;
}

function setTimeZone(prayerTimeOptions: PrayerTimesOptions, location: ICoords) {
if (!prayerTimeOptions.timezone) {
prayerTimeOptions.timezone = timeZoneLookup(location);
}
}

function setRounding(
prayerTimeOptions: PrayerTimesOptions,
roundingMethod?: typeof Rounding[keyof typeof Rounding]
Expand Down
Loading

0 comments on commit 94deb94

Please sign in to comment.