Skip to content

Commit

Permalink
Use yarn patch to patch suncalc3 instead of having a hard copy (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
scinos authored Nov 5, 2024
1 parent d03367a commit 40a3052
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 2,159 deletions.
63 changes: 63 additions & 0 deletions .yarn/patches/suncalc3-npm-2.0.5-9cdae05f76.patch
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}`);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
Expand Down
22 changes: 0 additions & 22 deletions suncalc3/LICENSE

This file was deleted.

25 changes: 0 additions & 25 deletions suncalc3/README-HORIZON-CARD.md

This file was deleted.

Loading

0 comments on commit 40a3052

Please sign in to comment.