-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Wrong sunrise time for negative timezones #12
Comments
Hello, could you describe all the steps you took for the entire process? In my tests everything is working correctly. Also, are you using the latest version or the GPL version? When I run |
@Hrsikesa108 it seems like you have inverted latitude and longitude, the geopos array in the Also, you can use the 3 moon degrees equals roughly 6 hours difference, check for conversion between UTC and local time for your timezone. const now = new Date();
const jd = utc_to_jd(
now.getUTCFullYear(),
now.getUTCMonth() + 1, // months in javascript Date start at 0
now.getUTCDate(),
now.getUTCHours(),
now.getUTCMinutes(),
now.getUTCSeconds() + now.getUTCMilliseconds() / 1000,
1 // gregorian calendar flag
);
const rise = rise_trans(
jd.data[1], // get jd_ut
0, // Sun
null,
2, // flag.SWIEPH,
1, // For rising
[79.51021061378489, 18.751372110577833, 170], // longitude first, latitude second
0,
0
);
const utc = jdut1_to_utc(
rise.data,
1 // gregorian calendar flag
);
const local = utc_time_zone(
utc.year,
utc.month,
utc.day,
utc.hour,
utc.minute,
utc.second,
-5.5 // time zone of -05:30
); |
Hi sir const getPanchanga = (now = new Date()) => {
} from use utc_time_zone function when given the timezone -5.5 i am getting below output which is showing 1 day extra when i use 1 without giving the time zone then it is giving the time of means 5hr.30 min extra from my current time |
I'm not sure i understand what your issue is. As i do not know your location or your time zone, i cannot see what is correct and what is incorrect from your code. The last parameter of the function If your time zone is GMT-6 (6 hours less than GMT, ie New York), the parameter should be Other than that i cannot help you without further information, like which values are incorrect and what values were you expecting to see. |
sir one small doubt , please dont feel bad, every time we should pass current time in utc format only right for all calculations? |
Yes, all swisseph calculations are always done in UTC. |
Hi sir, |
The function The code i showed you before in #12 (comment) should give you exactly the result you want. Start with the current time, use Javascript's Date methods to get the UTC parts, calculate the julian day, calculate rise trans, convert sunrise julian day back to calendar date, then convert the date to your timezone. |
I am trying to get sunrise time of:
I converted the above date time to UTC and then to julian date which came to: 2460218.7916674046
Then I used rise_trans function from sweph package. Here is the code
I am getting this result in Julian date: 2460218.928608603, when converted to UTC it becomes 2023-10-01 10:17:00 (which is wrong) because in local time the sunrise time becomes at 3:17 AM
The text was updated successfully, but these errors were encountered: