Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use yarn's patch protocol to patch suncalc3 #155

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:empty-npm-package@1.0.0"
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
Loading