Skip to content

Commit

Permalink
remove support for idealized timezones
Browse files Browse the repository at this point in the history
  • Loading branch information
bacalj committed Aug 7, 2024
1 parent b06eb08 commit 4e084fb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/hooks/useCodapData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ export const useCodapData = () => {
const calcOptions: DaylightCalcOptions = {
latitude: Number(latitude),
longitude: Number(longitude),
year: 2024, //TODO: If data are to be historical, add dynamic year attribute
useRealTimeZones: true
year: 2024 // NOTE: If data are to be historical, add dynamic year attribute
};

const solarEvents = getDayLightInfo(calcOptions);
Expand Down
1 change: 0 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export interface DaylightCalcOptions {
latitude: number;
longitude: number;
year: number;
useRealTimeZones: boolean;
}

export interface DaylightInfo {
Expand Down
13 changes: 3 additions & 10 deletions src/utils/daylight-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function getSunrayAngleInDegrees(dayNum: number, earthTilt: number, lat:n
}

export function getDayLightInfo(options: DaylightCalcOptions): DaylightInfo[] {
const { latitude, longitude, year, useRealTimeZones } = options;
const { latitude, longitude, year } = options;
const results: DaylightInfo[] = [];

let currentDay = dayjs.utc(`${year}-01-01`);
Expand All @@ -95,15 +95,8 @@ export function getDayLightInfo(options: DaylightCalcOptions): DaylightInfo[] {
// TODO: handle above arctic circle and below antarctic circle
const utcSunrise = dayjs(getSunrise(latitude, longitude, date));
const utcSunset = dayjs(getSunset(latitude, longitude, date));

// TODO: Consider removing fake timezone option entirely
const tzSunrise = useRealTimeZones
? utcSunrise.tz(timeZone)
: utcSunrise.add(Math.round(longitude / 15), "hour");

const tzSunset = useRealTimeZones
? utcSunset.tz(timeZone)
: utcSunset.add(Math.round(longitude / 15), "hour");
const tzSunrise = utcSunrise.tz(timeZone)
const tzSunset = utcSunset.tz(timeZone)

const record: DaylightInfo = {
day: currentDay.format("YYYY-MM-DD"),
Expand Down

0 comments on commit 4e084fb

Please sign in to comment.