干支纪年中之旬首、符头与旬空都是可以在干支序列中快速检视,下面是当天日干支之计算示例:
/* 日支st所属旬首 */
function findhead(st)
{
var b;
var a = gzall().indexOf(st);
switch(true){
case (a>-1&&a<20): b = "甲子"; break;
case (a>19&&a<40): b = "甲戌"; break;
case (a>39&&a<60): b = "甲申"; break;
case (a>59&&a<80): b = "甲午"; break;
case (a>79&&a<100): b = "甲辰"; break;
case (a>99): b = "甲寅"; break;
default: b = "";
}
return b;
}
/* 日支st所属符头 */
function futou(st)
{
var b, e;
var c = findhead(st);
var a = gzall().indexOf(st);
var d = a % 20;
switch(c){
case "甲子": b = "己巳"; break;
case "甲戌": b = "己卯"; break;
case "甲申": b = "己丑"; break;
case "甲午": b = "己亥"; break;
case "甲辰": b = "己酉"; break;
case "甲寅": b = "己未"; break;
default: d = "";
}
if(d<10) e = c;
else e = b;
return e;
}
/* 日支st所属旬空 */
function xunkon(st)
{
var a = Math.floor((gzall().indexOf(st)+1) / 20);
var str = "子丑寅卯辰巳午未申酉戌亥";
var b = (12 - (a * 2)) % 12;
var c = (b + 10) % 12;
return str.substr(c, 2);
}