Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
programming:stardate [2014/04/28 23:44] – Giuseppe Di Terlizzi | programming:stardate [2014/08/13 11:20] (current) – Giuseppe Di Terlizzi | ||
---|---|---|---|
Line 27: | Line 27: | ||
Come si può notare la differenza è incredibilmente piccola. | Come si può notare la differenza è incredibilmente piccola. | ||
È altrettanto evidente che la formula sopra indicata mal si presta ad un uso istantaneo e può assere meglio esplicitata nella seguente: | È altrettanto evidente che la formula sopra indicata mal si presta ad un uso istantaneo e può assere meglio esplicitata nella seguente: | ||
+ | |||
+ | {{: | ||
Nella quale: | Nella quale: | ||
Line 49: | Line 51: | ||
<code vb> | <code vb> | ||
<% | <% | ||
- | data = date() | + | dim k |
- | orario | + | |
+ | dim sData = date() | ||
+ | dim sOrario | ||
- | anno = year(data) | + | dim iAnno = year(sData) |
- | annoBase | + | dim iAnnoBase |
- | giorno | + | dim iGiorno |
- | giorniAnno | + | dim iGiorniAnno |
- | ora = hour(orario) | + | dim iOra = hour(sOrario) |
- | minuti | + | dim iMinuti |
- | secondi | + | dim iSecondi |
- | anno_normale | + | dim iAnnoNormale |
- | anno_bisestile | + | dim iAnnoBisestile |
- | if giorniAnno | + | if iGiorniAnno |
- | | + | |
- | elseif | + | elseif |
- | | + | |
end if | end if | ||
- | stardate | + | dim sStardate |
- | arr_stardate | + | dim aStardate |
- | short_stardate | + | dim sShortStardate |
%> | %> | ||
</ | </ | ||
Line 89: | Line 93: | ||
Salviamo il codice della formula, all' | Salviamo il codice della formula, all' | ||
- | < | + | < |
<!-- #include file = " | <!-- #include file = " | ||
< | < | ||
Line 96: | Line 100: | ||
< | < | ||
< | < | ||
- | Oggi è la data stellare <% response.write | + | Oggi è la data stellare <% response.write |
</ | </ | ||
</ | </ | ||
Line 109: | Line 113: | ||
$data = date(" | $data = date(" | ||
- | $anno = date(' | + | $anno |
- | $annoBase = "2323"; | + | $annoBase |
- | $giorno = (int)(abs(strtotime($data) - strtotime($anno." | + | $giorno |
$giorniAnno = (int)(abs(strtotime(($anno + 1)." | $giorniAnno = (int)(abs(strtotime(($anno + 1)." | ||
- | $ora = date(' | + | $ora = date(' |
- | $minuti = date(' | + | $minuti |
- | $secondi = date(' | + | $secondi |
- | $anno_normale = " | + | $anno_normale |
$anno_bisestile = " | $anno_bisestile = " | ||
Line 164: | Line 168: | ||
function StarDate() { | function StarDate() { | ||
- | var oggi = new Date(); | + | |
+ | day = oggi.getDate(), | ||
+ | month = oggi.getMonth(), | ||
+ | year = oggi.getYear(); | ||
- | var day = oggi.getDate(); | + | |
- | var month = oggi.getMonth(); | + | |
- | var year = oggi.getYear(); | + | |
- | + | ||
- | if (year < 1000) | + | |
var anno = (oggi.getYear() + 1900); | var anno = (oggi.getYear() + 1900); | ||
- | else if (year > 1000) | + | |
var anno = year; | var anno = year; | ||
- | var annoBase = " | + | |
- | var giorno = parseInt((((Date.parse((month + 1) + "/" | + | var giorno = parseInt((((Date.parse((month + 1) + "/" |
- | var giorniAnno = (((Date.parse(" | + | var giorniAnno = (((Date.parse(" |
- | var ora = oggi.getHours(); | + | var ora = oggi.getHours(); |
- | var minuti = oggi.getMinutes(); | + | var minuti = oggi.getMinutes(); |
- | var secondi = oggi.getSeconds(); | + | var secondi = oggi.getSeconds(); |
- | var anno_normale = "0.00003170979"; | + | |
- | var anno_bisestile = "0.00003162315"; | + | anno_bisestile = 0.00003162315; |
- | if (giorniAnno == 365) | + | |
var k = anno_normale; | var k = anno_normale; | ||
- | else if (giorniAnno == 366) | + | |
var k = anno_bisestile; | var k = anno_bisestile; | ||
- | var stardate = (((anno - annoBase) + (giorno / giorniAnno)) * 1000) + (((ora * 3600) + (minuti * 60) + secondi) * k); | + | |
- | var stardate_string = stardate + ''; | + | |
- | var arr_stardate = stardate_string.split(" | + | |
- | var short_stardate = arr_stardate[0] + " | + | var short_stardate = arr_stardate[0] + " |
- | document.getElementById(' | + | |
- | setTimeout(" | + | |
} | } | ||
</ | </ | ||
Line 243: | Line 247: | ||
* ASP Classic: | * ASP Classic: | ||
- | <code vb>stardate2 | + | <code vb>dim sStardate2 |
* PHP: | * PHP: | ||
Line 254: | Line 258: | ||
<code javascript> | <code javascript> | ||
+ | |||
+ | {{tag> |