-
Notifications
You must be signed in to change notification settings - Fork 1
/
yearsignaturedisplay.js.html
171 lines (152 loc) · 8.16 KB
/
yearsignaturedisplay.js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: yearsignaturedisplay.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: yearsignaturedisplay.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/**
* @file Milesian Year Signature Display routines.
* This package displays annual figures, in relation with yearsignaturedisplay.html.
* imported routines are accessed through object 'modules'.
* Only a few implementation comments are given here, since this code is mainly for demonstration purposes.
* @see yearsignaturedisplay.html
* @version M2022-12-15
* @author Louis A. de Fouquières https://github.com/Louis-Aime
* @license MIT 2016-2022
*/
// Character set is UTF-8
/* Version M2022-12-15 Display 22 March epact
See GitHub for former versions
*/
/* Copyright Louis A. de Fouquières https://github.com/Louis-Aime 2016-2022
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
1. The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
2. Changes with respect to any former version shall be documented.
The software is provided "as is", without warranty of any kind,
express of implied, including but not limited to the warranties of
merchantability, fitness for a particular purpose and noninfringement.
In no event shall the authors of copyright holders be liable for any
claim, damages or other liability, whether in an action of contract,
tort or otherwise, arising from, out of or in connection with the software
or the use or other dealings in the software.
*/
"use strict";
// These routines complement general display routines. Modules are loaded in "main" program under the "modules" wrapper.
function romanDateFrom21March (offset) {
return (offset <= 10)
? romanDateFormat.format(new Date (1800, 2, (offset + 21)))
: romanDateFormat.format(new Date (1800, 3, (offset - 10)));
}
function displayDOW (Day) { // Yield the string of the day of the week of rank Day. This one is limited to built-in calendar (traditional week)
return DOWFormat.format (new modules.ExtDate ("iso8601", 1970, 1, 4+Day))
}
/* function displayYeartype (type) {
var yearTypes = ["cave (et commune)", "longue (et commune)", "bissextile (et cave)"]
return yearTypes [type];
}*/
function computeSignature(year) { // Formaters are external
// Begin with common and Julian calendar figures
var signature = modules.julianSignature (year), m_signature = modules.milesianSignature (year);
// The specified year
document.yearglobal.year.value = year;
// Set gold number
document.yearglobal.gold.value = signature.goldNumber;
// Julian figures
document.details.j_type.value = signature.isLeap ? "bissextile" : "commune";
document.details.j_day.value = displayDOW (signature.doomsday);
document.details.j_dlet.value = signature.dominicalLetter;
document.details.j_epact.value = signature.epact;
document.details.j_epactMar22.value = signature.epactMar22;
document.details.j_residue.value = signature.easterResidue;
document.details.j_daynumber.value = signature.easterOffset;
document.details.j_romandate.value = romanDateFrom21March(signature.easterOffset);
document.details.j_referdate.value = lunarDateFormat.format (signature.easterDate);
// Gregorian and Milesian figures
signature = modules.gregorianSignature (year);
document.details.g_type.value = signature.isLeap ? "bissextile" : "commune";
document.details.m_type.value = m_signature.isLeap ? "abondante" : "cave" ;
document.details.g_day.value = displayDOW (signature.doomsday);
document.details.g_dlet.value = signature.dominicalLetter;
document.details.g_epact.value = signature.epact;
document.details.m_epact.value = m_signature.epact
document.details.g_residue.value = signature.easterResidue;
document.details.g_daynumber.value = signature.easterOffset;
document.details.g_romandate.value = romanDateFrom21March(signature.easterOffset);
document.details.g_referdate.value = lunarDateFormat.format (signature.easterDate);
// Seasons
document.getElementById ("seasonsyear").innerHTML = year;
try {
document.seasons.winter1.value = seasonDateFormat.format (modules.tropicEvent(year,0));
document.seasons.spring.value = seasonDateFormat.format (modules.tropicEvent(year,1));
document.seasons.summer.value = seasonDateFormat.format (modules.tropicEvent(year,2));
document.seasons.autumn.value = seasonDateFormat.format (modules.tropicEvent(year,3));
document.seasons.winter2.value = seasonDateFormat.format (modules.tropicEvent(year,4));
}
catch (e) { // seasons could not be computed, main reason is: year out of computational range
document.seasons.winter1.value =
document.seasons.spring.value =
document.seasons.summer.value =
document.seasons.autumn.value =
document.seasons.winter2.value = "-- -- -- -- --";
}
}
function setYear(year) {
year = Math.round(year); // Force to integer value
if (isNaN (year)) alert ("non Integer: " + document.yearglobal.year.value)
else {
document.yearglobal.year.value = +year;
computeSignature (+year);
}
}
function setYearOffset(shift) {
shift = Math.round(shift); // Force to integer value
let year = Math.round(document.yearglobal.year.value) + Math.round(shift);
if (year == NaN) alert ("non Integer: " + '"' + document.yearglobal.shift.value + '" "' + document.yearglobal.year.value + '"')
else if (year < -271820 || year > 275760) alert ("Year out of range")
else {
document.yearglobal.year.value = +year;
// targetDate.setFromFields ({ year: year},"UTC");
computeSignature (+year);
}
}
function setYearToNow(myCalendar=milesian){ // Self explanatory
targetDate = new modules.ExtDate(myCalendar);
// set to the middle of the year
targetDate.setUTCHours (0, 0, 0, 0);
targetDate.setFromFields ( { day: 1, month: 7 } ,"UTC");
setYear(targetDate.fullYear());
}
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-calendarclock.html">calendarclock</a></li><li><a href="module-countconversion.html">countconversion</a></li><li><a href="module-deltat.html">deltat</a></li><li><a href="module-lunar.html">lunar</a></li><li><a href="module-seasons.html">seasons</a></li><li><a href="module-yearsignature.html">yearsignature</a></li></ul><h3>Classes</h3><ul><li><a href="module-calendarclock.SolarClock.html">SolarClock</a></li><li><a href="module-countconversion.ExtCountDate.html">ExtCountDate</a></li><li><a href="timeShift.html">timeShift</a></li></ul><h3>Interfaces</h3><ul><li><a href="clockAnimate.html">clockAnimate</a></li><li><a href="myTimeShift.html">myTimeShift</a></li></ul><h3>Global</h3><ul><li><a href="global.html#calcCustomDate">calcCustomDate</a></li><li><a href="global.html#calcJulianDay">calcJulianDay</a></li><li><a href="global.html#calcTime">calcTime</a></li><li><a href="global.html#calcWeek">calcWeek</a></li><li><a href="global.html#setDateToNow">setDateToNow</a></li><li><a href="global.html#setDateToToday">setDateToToday</a></li><li><a href="global.html#setUTCHoursFixed">setUTCHoursFixed</a></li><li><a href="global.html#undef">undef</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a> on Mon Apr 15 2024 21:10:03 GMT+0200 (heure d’été d’Europe centrale)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>