Skip to content

Commit

Permalink
Sunrise Set for timezones,
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjayPrabhakaran committed Jun 5, 2024
1 parent b10789e commit 713d10f
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 17 deletions.
4 changes: 2 additions & 2 deletions SJPv6/www/SJP.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
</td>
</tr>
<tr>
<td>Time Zone:
<td>Time Zone: (In Decimals. Use -ve value for west of UT)
</td>
<td>
<input id=timezone name=timezone type=text size=5 value="+5.5"><br/>
<input id=timezone name=timezone patter="\d+[\.]*\d*" type=text size=5 value="+5.5"><br/>
</td>
</tr>
<tr>
Expand Down
63 changes: 63 additions & 0 deletions SJPv6/www/experiment.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!DOCTYPE html>
<html>
<head>
<style>
.myDiv {
border: 5px outset red;
background-color: lightblue;
text-align: center;
}
</style>
</head>
<body>
<script>
class ClickExpand{
static count=0;
secname="";
constructor(short_txt,exp_txt,childof=null){
alert(123);
this.short_txt=short_txt;
this.exp_txt=exp_txt;
alert(short_txt);
try {this.secname="ClkExp"+ClickExpand.count; }catch(err) { alert(err.message);}

alert(this.secname);

alert(ClickExpand.count);
ClickExpand.count++;
this.htm=`<section
id=${this.secname}>
<a href="javascript:e=document.createElement('section');e.innerHTML='${exp_txt}';document.getElementById('${this.secname}').appendChild(e);alert(e);">${short_txt}</a></section>`;
if(childof != null)
{
this.Addto(childof);
}
alert(this.htm);
}
SetText(short_text,exp_text){
}
Addto(element_id){
var element = document.getElementById(element_id);
//s=element.createElement("section");
element.innerHTML=this.htm;
}
}

</script>

<div id="kcddiv"><a href="javascript:document.getElementById('kcddiv').appendChild(document.createTextNode('<strong>asd</strong>'))"><strong>KCD Dasa</strong></a></div>

<div id="kcddiv2">
two
<a href="javascript:e=document.createElement('p');e.setAttribute('ID','kcddiv2text');e.innerHTML='<strong>asd</strong>';document.getElementById('kcddiv2').appendChild(e);alert(e);"><strong>KCD Dasa</strong></a></div>

<section id="test">section</section>
<script>
var x;
x= new ClickExpand("short text","<strong>innter text in bold</strong>");
x.Addto('test');
</script>
<p>This is some text outside the div element.</p>

</body>
</html>
55 changes: 40 additions & 15 deletions SJPv6/www/sjp.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Date.prototype.day=1;
Date.prototype.month=1;
Date.prototype.year=1;

var minutes = 1000 * 60; //Milliseconds
var hours = minutes * 60;//Milliseconds
var day = hours * 24;//Milliseconds
var minutes = 1000 * 60; //Milliseconds
var hours = minutes * 60;//Milliseconds
var day = hours * 24;//Milliseconds
var kali2julian = 588466;//Ahargana to subtract from Julian date to get kali ahargana.
var t; //t : number of Julian centuries since J2000.0 t = ((jd - 2415020) + f/24 - 0.5)/36525;
var nakshatra =["Ashvini-Ke","Bharani-Ve","Kritika-Su","Rohini-Mo","Mrigashira-Ma","Ardra-Ra","Punarvasu-Ju","Pushya-Sa","Ashlesha-Me","Magha-Ke","Purva Phalguni-Ve","Uttara Phalguni-Su","Hasta-Mo","Chitra-Ma","Swati-Ra","Vishakha-Ju","Anuradha-Sa","Jyeshtha-Me","Mula-Ke","Purva Ashadha-Ve","Uttara Ashadha-Su","Shravan-Mo","Dhanistha-Ma","Shatabhishaj-Ra","Purva Bhadrapad-Ju","Uttara Bhadrapad-Sa","Revati-Me"];
Expand Down Expand Up @@ -180,6 +180,18 @@ Date.prototype.getKaliAbda=function(){
return KaliYear;
}

Date.prototype.setLocalHMS0=function(){
this.setHours(0);
this.setMinutes(0);
this.setSeconds(0);
this.setMilliseconds(0);
}
Date.prototype.setUtcHMS0=function(){
this.setUTCHours(0);
this.setUTCMinutes(0);
this.setUTCSeconds(0);
this.setUTCMilliseconds(0);
}
Date.prototype.getMyTimezoneOffset=function(){
if(Date.MyTimezoneOffset == null){
var t=new Date();
Expand Down Expand Up @@ -453,22 +465,27 @@ function getPanchanga(date_time,longitude,latitude){
}
this.moon_cur = this.grahas.grahas[1];
this.sun_cur = this.grahas.grahas[0];
this.sunrise = new Date(date_time);
this.sunrise_next = new Date(date_time);
this.sunrise = new Date(cur_date);
this.sunrise_next = new Date(cur_date+day);
this.sunrise.setLocalHMS0();
this.sunrise_next.setLocalHMS0();
var adjust = 0; // Adjust Time Sun rise/set time if needed.
if(this.date_time < new Date("1 Jan 1970")) adjust=day; //This adjust is needed for days in -ve it seems
// if(this.date_time < new Date("1 Jan 1970")) adjust=day; //This adjust is needed for days in -ve it seems
var sr= calcSunriseGMT(dateToJul(cur_date),latitude,longitude);
var sr2= calcSunriseGMT(dateToJul(cur_date+day),latitude,longitude);
this.sunrise.setTime(parseInt(cur_date/day)*day -adjust + sr*minutes);
this.sunrise_next.setTime(parseInt(cur_date/day)*day+day -adjust+ sr2*minutes);
this.sunset = new Date(date_time);
this.sunrise.setMinutes(-adjust + sr-date_time.getMyTimezoneOffset());//this.sunrise.setTime(parseInt(cur_date/day)*day -adjust + sr*minutes);
this.sunrise_next.setMinutes(-adjust+ sr2-date_time.getMyTimezoneOffset());//this.sunrise_next.setTime(parseInt(cur_date/day)*day+day -adjust+ sr2*minutes);
this.sunset = new Date(cur_date);
this.sunset.setLocalHMS0();
var ss= calcSunsetGMT(dateToJul(cur_date),latitude,longitude);
this.sunset.setTime(parseInt(cur_date/day)*day -adjust+ ss*minutes);
this.noon = new Date(date_time);
this.midnight = new Date(date_time);
this.sunset.setMinutes(-adjust + ss-date_time.getMyTimezoneOffset());//.setTime(parseInt(cur_date/day)*day -adjust+ ss*minutes);
this.noon = new Date(cur_date);
this.noon.setLocalHMS0();
this.midnight = new Date(cur_date);
this.midnight.setLocalHMS0();
var n= calcSolNoonGMT(dateToJul(cur_date),longitude);
this.noon.setTime(parseInt(cur_date/day)*day -adjust+ n*minutes);
this.midnight.setTime(parseInt(cur_date/day)*day -adjust+ (n+12*60)*minutes);
this.noon.setMinutes(-adjust + n-date_time.getMyTimezoneOffset());//.setTime(parseInt(cur_date/day)*day -adjust+ n*minutes);
this.midnight.setMinutes(-adjust + (n+12*60)-date_time.getMyTimezoneOffset());//.setTime(parseInt(cur_date/day)*day -adjust+ (n+12*60)*minutes);
this.AscData2 = new calculateAscendant(this.sunrise,latitude,longitude);
this.AscData3 = new calculateAscendant(this.sunrise_next,latitude,longitude);
this.sun_begin = this.AscData2.Ascendant+1.151008333;
Expand Down Expand Up @@ -591,7 +608,7 @@ function getPanchanga(date_time,longitude,latitude){
this.html+= "\n<br/><b>Kali Abda:</b>"+date_time.getKaliAbda();
this.html+= "\n<br/><b>Ahargana:</b>"+date_time.getAhargana();
this.html+= "\n<br/><b>Saura Maasa </b>"+this.sSauraMaasa;
this.html+= "\n<br/><b>Ishta Ghati <b>"+((Date.parse(this.date_time)-Date.parse(this.sunrise))/minutes/24).toFixed(4);
this.html+= "\n<br/><b>Ishta Ghati <b>"+(((Date.parse(this.date_time)-Date.parse(this.sunrise))/minutes)/24).toFixed(4);
this.html+= "\n<br/><b> Ayanamsha:</b>" + toDeg(this.AscData.Ayanamsa)+
"\n<br/><br/>";

Expand Down Expand Up @@ -1591,6 +1608,7 @@ function LoadFile(p){
function getGrahasEph(date_time,lat,lon){
this.grahas = new MyArray(9);
this.speed = new MyArray(7);
this.body = new MyArray(9);

tz_date=new Date(date_time);
tz_date.setMinutes(tz_date.getMinutes()+tz_date.getMyTimezoneOffset())
Expand Down Expand Up @@ -1618,33 +1636,38 @@ function getGrahasEph(date_time,lat,lon){
var body = $moshier.body.sun;
$processor.calc (date, body);
this.grahas[0]=body.position.apparentLongitude;
this.body[0]=body;
console.log(body.position);
$processor.calc (date2, body);
this.speed[0]=((360+body.position.apparentLongitude-this.grahas[0])%360)/day;

body = $moshier.body.moon;
$processor.calc (date, body);
this.grahas[1]=body.position.apparentLongitude;
this.body[1]=body;
console.log(body.position);
$processor.calc (date2, body);
this.speed[1]=((360+body.position.apparentLongitude-this.grahas[1])%360)/day;

body = $moshier.body.mars;
$processor.calc (date, body);
this.grahas[2]=body.position.apparentLongitude;
this.body[2]=body;
console.log(body.position);
$processor.calc (date2, body);
this.speed[2]=((360+body.position.apparentLongitude-this.grahas[2])%360)/day;

body = $moshier.body.mercury;
$processor.calc (date, body);
this.grahas[3]=body.position.apparentLongitude;
this.body[3]=body;
$processor.calc (date2, body);
this.speed[3]=((360+body.position.apparentLongitude-this.grahas[3])%360)/day;

body = $moshier.body.jupiter;
$processor.calc (date, body);
this.grahas[4]=body.position.apparentLongitude;
this.body[4]=body;
console.log(body.position);
$processor.calc (date2, body);
this.speed[4]=((360+body.position.apparentLongitude-this.grahas[4])%360)/day;
Expand All @@ -1653,13 +1676,15 @@ function getGrahasEph(date_time,lat,lon){
body = $moshier.body.venus;
$processor.calc (date, body);
this.grahas[5]=body.position.apparentLongitude;
this.body[5]=body;
console.log(body.position);
$processor.calc (date2, body);
this.speed[5]=((360+body.position.apparentLongitude-this.grahas[5])%360)/day;

body = $moshier.body.saturn;
$processor.calc (date, body);
this.grahas[6]=body.position.apparentLongitude;
this.body[6]=body;
console.log(body.position);
$processor.calc (date2, body);
this.speed[6]=((360+body.position.apparentLongitude-this.grahas[6])%360)/day;
Expand Down

0 comments on commit 713d10f

Please sign in to comment.