我怎样才能在日落和日出之间得到半夜 [英] How can I get middle of night between sunset and sunrise

查看:99
本文介绍了我怎样才能在日落和日出之间得到半夜的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以得到两次,在日落和日出之间的半夜,在日落和日落之间的深夜,所以我不想只获得其中一个?

我需要在相同的浏览器中获得日落到日出的中间时间和日落到Fajr的时间中间,这里是javascript:[http://praytimes.org /code/v2/js/PrayTimes.js](http://praytimes.org/code/v2/js/PrayTimes.js)这里是HTML每月祷告时间[http://praytimes.org/code/v2 /js/examples/monthly.htm](http://praytimes.org/code/v2/js/examples/monthly.htm)我想编辑Js文件,这样我就可以在HTML文件中同时获取

我需要对此代码进行哪些更改?



我尝试了什么:



我试图更改java脚本文件但是没有工作,更改如下:







Who can I get two times, 1- middle of night between Sunset and sunrise 2- middle of night between Sunset and fajr so I do not want to get just one of them?
I need to get Middle of the time of Sunset to Sunrise and Middle of the time of the time of Sunset to Fajr at the same browser, here is the javascript: [http://praytimes.org/code/v2/js/PrayTimes.js](http://praytimes.org/code/v2/js/PrayTimes.js) and here is the HTML monthly prayer times [http://praytimes.org/code/v2/js/examples/monthly.htm](http://praytimes.org/code/v2/js/examples/monthly.htm) I want to edit the Js file so I can get both times in the HTML file
what changes I needs to make to this code?

What I have tried:

I tried to change java script file but did not work the change is as following:



<title>Page Title




	
		body, tr, form {font-family: tahoma; font-size: 12px; color: #404040; text-align: center; margin: 0; padding: 0}
		pre {font-family: courier, serif, size: 10pt; margin: 0px 8px;}
		input {font-size: 12px;}
		.header {background:#eef; border-bottom: 1px solid #ddd; padding: 7px;}
		.caption {font-size: 20px; color: #d95722; text-align: center; width: 10em;}
		.arrow {font-weight: bold; text-decoration: none; color: #3D3D3D; }
		.arrow:hover {text-decoration: underline;}
		.command {font-weight: bold; text-decoration: none; color: #AAAAAA; }
		.command:hover {text-decoration: underline;}
		.timetable {border-width: 1px; border-style: outset; border-collapse: collapse; border-color: gray; margin: 0 auto;}
		.timetable td {border-width: 1px; border-spacing: 1px; padding: 1px; border-style: inset; border-color: #CCCCCC;}
		.head-row {color: black; background-color: #eef;}
		.today-row {background-color: #ffff00; color: black}
	






<div class="header">


	Latitude:  
	Longitude:  
	Time Zone:  
	DST: 
	
		Auto
		0
		1
     
	Method: 
	
		 Leva Institute, Qum 
                Institute of Geophysics, University of Tehran
                Muslim World League (MWL)
		Islamic Society of North America (ISNA)
		Egyptian General Authority of Survey
		Umm al-Qura University, Makkah
		University of Islamic Sciences, Karachi
		
    

</div>
<br>

<table align="center"><tbody><tr>	<td><a class="arrow"><<</a></td>	<td id="table-title" class="caption"></td>	<td><a class="arrow">>></a></td></tr></tbody></table>

<br>

	<table id="timetable" class="timetable"><tbody></tbody></table>

<div align="center" style="margin-top: 7px">
	
	Time Format: <a id="time-format" title="Change clock format" class="command"></a>
</div>
<br>



	var currentDate = new Date();
	var timeFormat = 1; 
	switchFormat(0);

	// display monthly timetable
	function displayMonth(offset) {
		var lat = $('latitude').value;
		var lng = $('longitude').value;
		var timeZone = $('timezone').value;
		var dst = $('dst').value;
		var method = $('method').value;

		prayTimes.setMethod(method);
		currentDate.setMonth(currentDate.getMonth()+ 1* offset);
		var month = currentDate.getMonth();
		var year = currentDate.getFullYear();
		var title = monthFullName(month)+ ' '+ year;
		$('table-title').innerHTML = title;
		makeTable(year, month, lat, lng, timeZone, dst);
	}

	// make monthly timetable
	function makeTable(year, month, lat, lng, timeZone, dst) {		
		var items = {day: 'Day', imsak    : 'Imsak',fajr: 'Fajr', sunrise: 'Sunrise', 
					dhuhr: 'Dhuhr', asr: 'Asr', sunset: 'Sunset', 
					maghrib: 'Maghrib',  isha: 'Isha',midnight1 : 'Midnight1' ,midnight2 : 'Midnight2'};
				
		var tbody = document.createElement('tbody');
		tbody.appendChild(makeTableRow(items, items, 'head-row'));

		var date = new Date(year, month, 1);
		var endDate = new Date(year, month+ 1, 1);
		var format = timeFormat ? '12hNS' : '24h';

		while (date < endDate) {

			var times = prayTimes.getTimes(date, [lat, lng], timeZone, dst, format);

			times.day = date.getDate();

			var today = new Date(); 

			var isToday = (date.getMonth() == today.getMonth()) && (date.getDate() == today.getDate());

			var klass = isToday ? 'today-row' : '';

			tbody.appendChild(makeTableRow(times, items, klass));

			date.setDate(date.getDate()+ 1);  // next day

		}

		removeAllChild($('timetable'));

		$('timetable').appendChild(tbody);

	}



	// make a table row

	function makeTableRow(data, items, klass) {

		var row = document.createElement('tr');

		for (var i in items) {

			var cell = document.createElement('td');

			cell.innerHTML = data[i];

			cell.style.width = i=='day' ? '2.5em' : '3.7em';

			row.appendChild(cell);

		}

		row.className = klass;

		return row;		

	}



	// remove all children of a node

	function removeAllChild(node) {

		if (node == undefined || node == null)

			return;



		while (node.firstChild)

			node.removeChild(node.firstChild);

	}



	// switch time format

	function switchFormat(offset) {

		var formats = ['24-hour', '12-hour'];

		timeFormat = (timeFormat+ offset)% 2;

		$('time-format').innerHTML = formats[timeFormat];

		update();

	}



	// update table

	function update() {

		displayMonth(0);

	}



	// return month full name

	function monthFullName(month) {

		var monthName = new Array('January', 'February', 'March', 'April', 'May', 'June', 

						'July', 'August', 'September', 'October', 'November', 'December');

		return monthName[month];

	}



	function $(id) {

		return document.getElementById(id);

	}









and the html is:

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
	<script type="text/javascript" src= charset="UTF-8"></script><style>
		body, tr, form {font-family: tahoma; font-size: 12px; color: #404040; text-align: center; margin: 0; padding: 0}
		pre {font-family: courier, serif, size: 10pt; margin: 0px 8px;}
		input {font-size: 12px;}
		.header {background:#eef; border-bottom: 1px solid #ddd; padding: 7px;}
		.caption {font-size: 20px; color: #d95722; text-align: center; width: 10em;}
		.arrow {font-weight: bold; text-decoration: none; color: #3D3D3D; }
		.arrow:hover {text-decoration: underline;}
		.command {font-weight: bold; text-decoration: none; color: #AAAAAA; }
		.command:hover {text-decoration: underline;}
		.timetable {border-width: 1px; border-style: outset; border-collapse: collapse; border-color: gray; margin: 0 auto;}
		.timetable td {border-width: 1px; border-spacing: 1px; padding: 1px; border-style: inset; border-color: #CCCCCC;}
		.head-row {color: black; background-color: #eef;}
		.today-row {background-color: #ffff00; color: black}
	</style>
</head>

<body>

<script type="text/javascript" src="PrayTimes.js"></script>

<div class="header">
<form class="form" action="javascript:update();">
Melbourne
	Latitude: <input type="text" value="-37.815018" id="latitude" size="2" onchange="update();" />&nbsp;
	Longitude: <input type="text" value="144.946014" id="longitude" size="2" onchange="update();" />&nbsp;
	Time Zone: <input type="text" value="+10" id="timezone" size="2" onchange="update();" />&nbsp;
	DST: 
	<select id="dst" size="1" style="font-size: 12px;" onchange="update()">
		<option value="auto" selected="selected">Auto</option>
		<option value="0">0</option>
		<option value="1">1</option>
    </select>&nbsp;
	Method: 
	<select id="method" size="1" style="font-size: 12px;" onchange="update()">
		<option value="Jafari" selected="selected"> Leva Institute, Qum </option>
                <option value="Tehran">Institute of Geophysics, University of Tehran</option>
                <option value="MWL">Muslim World League (MWL)</option>
		<option value="ISNA">Islamic Society of North America (ISNA)</option>
		<option value="Egypt">Egyptian General Authority of Survey</option>
		<option value="Makkah">Umm al-Qura University, Makkah</option>
		<option value="Karachi">University of Islamic Sciences, Karachi</option>
		
    </select>
</form>
</div>
<br/>
<table align="center">
<tr>
	<td><a href="javascript:displayMonth(-1)" class="arrow">&lt;&lt;</a></td>
	<td id="table-title" class="caption"></td>
	<td><a href="javascript:displayMonth(+1)" class="arrow">&gt;&gt;</a></td>
</tr>
</table>

<br/>
<table id="timetable" class="timetable">
	<tbody></tbody>
</table>

<div align="center" style="margin-top: 7px">
	
	Time Format: <a id="time-format" href="javascript:switchFormat(1)" title="Change clock format" class="command"></a>
</div>
<br/>

<script type="text/javascript">

	var currentDate = new Date();
	var timeFormat = 1; 
	switchFormat(0);

	// display monthly timetable
	function displayMonth(offset) {
		var lat = $('latitude').value;
		var lng = $('longitude').value;
		var timeZone = $('timezone').value;
		var dst = $('dst').value;
		var method = $('method').value;

		prayTimes.setMethod(method);
		currentDate.setMonth(currentDate.getMonth()+ 1* offset);
		var month = currentDate.getMonth();
		var year = currentDate.getFullYear();
		var title = monthFullName(month)+ ' '+ year;
		$('table-title').innerHTML = title;
		makeTable(year, month, lat, lng, timeZone, dst);
	}

	// make monthly timetable
	function makeTable(year, month, lat, lng, timeZone, dst) {		
		var items = {day: 'Day', imsak    : 'Imsak',fajr: 'Fajr', sunrise: 'Sunrise', 
					dhuhr: 'Dhuhr', asr: 'Asr', sunset: 'Sunset', 
					maghrib: 'Maghrib',  isha: 'Isha',midnight1 : 'Midnight1' ,midnight2 : 'Midnight2'};
				
		var tbody = document.createElement('tbody');
		tbody.appendChild(makeTableRow(items, items, 'head-row'));

		var date = new Date(year, month, 1);
		var endDate = new Date(year, month+ 1, 1);
		var format = timeFormat ? '12hNS' : '24h';

		while (date < endDate) {
			var times = prayTimes.getTimes(date, [lat, lng], timeZone, dst, format);
			times.day = date.getDate();
			var today = new Date(); 
			var isToday = (date.getMonth() == today.getMonth()) && (date.getDate() == today.getDate());
			var klass = isToday ? 'today-row' : '';
			tbody.appendChild(makeTableRow(times, items, klass));
			date.setDate(date.getDate()+ 1);  // next day
		}
		removeAllChild($('timetable'));
		$('timetable').appendChild(tbody);
	}

	// make a table row
	function makeTableRow(data, items, klass) {
		var row = document.createElement('tr');
		for (var i in items) {
			var cell = document.createElement('td');
			cell.innerHTML = data[i];
			cell.style.width = i=='day' ? '2.5em' : '3.7em';
			row.appendChild(cell);
		}
		row.className = klass;
		return row;		
	}

	// remove all children of a node
	function removeAllChild(node) {
		if (node == undefined || node == null)
			return;

		while (node.firstChild)
			node.removeChild(node.firstChild);
	}

	// switch time format
	function switchFormat(offset) {
		var formats = ['24-hour', '12-hour'];
		timeFormat = (timeFormat+ offset)% 2;
		$('time-format').innerHTML = formats[timeFormat];
		update();
	}

	// update table
	function update() {
		displayMonth(0);
	}

	// return month full name
	function monthFullName(month) {
		var monthName = new Array('January', 'February', 'March', 'April', 'May', 'June', 
						'July', 'August', 'September', 'October', 'November', 'December');
		return monthName[month];
	}

	function $(id) {
		return document.getElementById(id);
	}

</script>
</body>
</html>

推荐答案

('latitude').value;
\t\tvar lng =
('latitude').value; var lng =


('longitude').value;
\t\tvar timeZone =
('longitude').value; var timeZone =


('timezone').value;
\t\tvar dst =
('timezone').value; var dst =


这篇关于我怎样才能在日落和日出之间得到半夜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆