forked from AitorDB/home-assistant-sun-card
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use yarn patch to patch suncalc3 instead of having a hard copy (#155)
- Loading branch information
Showing
8 changed files
with
70 additions
and
2,159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
diff --git a/suncalc.js b/suncalc.js | ||
index bcd8a159e55c63e21dfd93f262ecca46b04b3733..d0a9d3b16fc993cc2d063011019498050935c1bc 100644 | ||
--- a/suncalc.js | ||
+++ b/suncalc.js | ||
@@ -543,7 +543,7 @@ | ||
* @param {boolean} [inUTC=false] defines if the calculation should be in utc or local time (default is local) | ||
* @return {ISunTimeList} result object of sunTime | ||
*/ | ||
- SunCalc.getSunTimes = function (dateValue, lat, lng, height, addDeprecated, inUTC) { | ||
+ SunCalc.getSunTimes = function (dateValue, lat, lng, height, addDeprecated, inUTC, dateAsIs) { | ||
// console.log(`getSunTimes dateValue=${dateValue} lat=${lat}, lng=${lng}, height={height}, noDeprecated=${noDeprecated}`); | ||
if (isNaN(lat)) { | ||
throw new Error('latitude missing'); | ||
@@ -552,11 +552,16 @@ | ||
throw new Error('longitude missing'); | ||
} | ||
// @ts-ignore | ||
- const t = new Date(dateValue); | ||
- if (inUTC) { | ||
- t.setUTCHours(12, 0, 0, 0); | ||
+ let t | ||
+ if (dateAsIs) { | ||
+ t = dateValue | ||
} else { | ||
- t.setHours(12, 0, 0, 0); | ||
+ t = new Date(dateValue); | ||
+ if (inUTC) { | ||
+ t.setUTCHours(12, 0, 0, 0); | ||
+ } else { | ||
+ t.setHours(12, 0, 0, 0); | ||
+ } | ||
} | ||
|
||
const lw = rad * -lng; | ||
@@ -1064,18 +1069,23 @@ | ||
* @param {boolean} [inUTC] defines if the calculation should be in utc or local time (default is local) | ||
* @return {IMoonTimes} result object of sunTime | ||
*/ | ||
- SunCalc.getMoonTimes = function (dateValue, lat, lng, inUTC) { | ||
+ SunCalc.getMoonTimes = function (dateValue, lat, lng, inUTC, dateAsIs) { | ||
if (isNaN(lat)) { | ||
throw new Error('latitude missing'); | ||
} | ||
if (isNaN(lng)) { | ||
throw new Error('longitude missing'); | ||
} | ||
- const t = new Date(dateValue); | ||
- if (inUTC) { | ||
- t.setUTCHours(0, 0, 0, 0); | ||
+ let t | ||
+ if (dateAsIs) { | ||
+ t = dateValue | ||
} else { | ||
- t.setHours(0, 0, 0, 0); | ||
+ t = new Date(dateValue); | ||
+ if (inUTC) { | ||
+ t.setUTCHours(0, 0, 0, 0); | ||
+ } else { | ||
+ t.setHours(0, 0, 0, 0); | ||
+ } | ||
} | ||
dateValue = t.valueOf(); | ||
// console.log(`getMoonTimes lat=${lat} lng=${lng} dateValue=${dateValue} t=${t}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ | |
"dependencies": { | ||
"custom-card-helpers": "^1.8.0", | ||
"lit": "^2.7.2", | ||
"suncalc3": "link:suncalc3" | ||
"suncalc3": "patch:suncalc3@npm%3A2.0.5#~/.yarn/patches/suncalc3-npm-2.0.5-9cdae05f76.patch" | ||
}, | ||
"resolutions": { | ||
"@formatjs/intl-utils": "npm:[email protected]" | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.