c4se記:さっちゃんですよ☆

.。oO(さっちゃんですよヾ(〃l _ l)ノ゙☆)

.。oO(此のblogは、主に音樂考察Programmingに分類されますよ。ヾ(〃l _ l)ノ゙♬♪♡

音樂はSoundCloud等バラバラの場所に公開中です。申し訳ないがlinkをたどるなどして探してください。

考察は現在は主に此のblogで公表中です。

programmingは、ひろくみせるものはGitHubで、個人的なものはBitBucketで開発中です。

c4se

ユーラル帝国の暦

ユーラル帝国の暦が、ついに公開されます。

ユーラル曆(イリア紀元)
 http://c4se.sakura.ne.jp/ta_YuraruReki.html

わーいわーい。
(debugにかなりかかったので嬉しい。)
ちなみに。OperaFirefoxでしか動きません。MSIESafariChromeは駄目です。多重代入を使っているからです。
また、いつか書き直します。
ブラウザを多重代入対応にする方法は思いつかないので……。


構成文件(ファイル)は、
・ta_YuraruReki.html
・ta_YuraruReki.js
の二点です。
ta_YuraruReki.jsは、単独でも使えるユーラル暦エンジンになっています。
コード公開。

/*
 * c4se project
 * Yuraru.Date.js 0.1 - 20090122
 *
 * project name: Yuraru for Gardea
 * project leader: Haruna Tachibana
 *                   tachibana.haruna@gmail.com
 *                   http://c4se.sakura.ne.jp/ta_index.html
 * author: Nemu Inoue
 *           utakata.c4se@gmail.com
 *           http://c4se.sakura.ne.jp/ne_index.html
 * license: c4seFCL 0.1
 */

if(!Object.prototype._className){
  Object.prototype._className = "Object";
  Array.prototype._className = "Array";
  String.prototype._className = "String";
  Number.prototype._className = "Number";
  Date.prototype._className = "Date";
  Error.prototype._className = "Error";
}
try{Yuraru;}catch(e){Yuraru = {};};
Date.FullUTC = function(fy, mo, da, ho, mi, se, ms){
  var d = new Date();
  d.setUTCFullYear(fy); // fy = FullYear
  d.setUTCMonth(mo);
  d.setUTCDate(da);
  d.setUTCHours(ho);
  d.setUTCMinutes(mi);
  d.setUTCSeconds(se);
  d.setUTCMilliseconds(ms);
  return d.getTime();
};

(function(){

/* 以下Engine部 */
var _ys = -127717808400000 / 1000 * 2; // YurukanoyusSyun_0 == -2079/10/14 0:00:00 GMT+0900 (JMT)
var _jmtms = 9*60*60*1000;
var _lms = (new Date()).getTimezoneOffset();
/*var _date = [0,31,28,31,30,31,30,31,31,30,31,30,31];
var leap = function(y){
  if(y%4 != 0) return false;
  if(y%100 != 0) return true;
  if(y%400 != 0) return false;
  return true;
};
var date = function(m, y){return ((m == 2)&&leap(y))? _date[2]+1: _date[m]};*/
var yd2ys = function(yd){return (((((yd[0]>0 ? yd[0]-1 : yd[0])*15 + yd[1]-1)*20 + yd[2])*60 + yd[3])*60 + yd[4])*60 + yd[5] + _ys;};
var ys2yd = function(ys){
  var rm = function(m, n){
    var k = m % n;
    if(k < 0) k += n;
    return [(m-k)/n, k];
  };
  var yd = [];
  ys = Math.floor(ys);
  ys -= _ys;
  [yd[yd.length], ys] = [Math.floor(ys/64800000), ys-(Math.floor(ys/64800000)*64800000)]; // 64800000 == 60 * 60 * 60 * 20 * 15
  [yd[yd.length], ys] = rm(ys, 4320000); //4320000 == 60 * 60 * 60 * 20
  [yd[yd.length], ys] = rm(ys, 216000); // 216000 == 60 * 60 * 60
  [yd[yd.length], ys] = rm(ys, 3600); // 3600 == 60 * 60
  [yd[yd.length], ys] = rm(ys, 60);
  yd.push(ys);
  yd[0] = (yd[0] > 0) ? yd[0] + 1 : yd[0];
  yd[1] = (yd[1] > 0) ? yd[1] + 1 : yd[1];
  return yd;
};
var d2ms = function(ud){return Date.FullUTC(ud[0], ud[1], ud[2], ud[3], ud[4], ud[5], ud[6]);};
var ms2d = function(ums){
  var d = new Date();
  d.setTime(ums/* + d.getTimezoneOffset()*60*1000*/);
  return [d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()];
};
var ys2ums = function(ys){return ys/2*1000;};
var ums2ys = function(ums){return ums/1000*2;};
var ud2yd = function(ud){return ys2yd(ums2ys(d2ms(ud)));};
var yd2ud = function(yd){return ms2d(ys2ums(yd2ys(yd)));};
var ld2ud = function(ld){
  var d = new Date(ld[0], ld[1], ld[2], ld[3], ld[4], ld[5], ld[6]);
  return ms2d(Date.FullUTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()));
};
var ud2ld = function(ud){
  return ms2d(d2ms(ud) - _lms * 60 * 1000);
};
var ld2yd = function(ld){return ud2yd(ld2ud(ld));};
var yd2ld = function(yd){return ud2ld(yd2ud(yd));};
//var jmtd2jmtms = function(jmtd){return d2ms(jmtd) + _jmtms;};
//var jmtms2jmtd = function(jmtms){return ms2d(jmtms - _jmtms);};
var ud2jmtd = function(ud){return ms2d(d2ms(ud) + _jmtms);};//{return jmtms2jmtd(d2ms(ud) + _jmtms);};
var jmtd2ud = function(jmtd){return ms2d(d2ms(jmtd) - _jmtms);};//{return ms2d(jmtd2jmtms(jmtd) - _jmtms);};
var nowYd = function(){
  var d = new Date();
  return ud2yd([d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()]);
};


/* 以下Interface部 */
Yuraru.Date = function(/*yd or arguments*/){
  var yd = []; var ys = 0;
  if(!arguments[0]){
    yd = nowYd(); ys = yd2ys(yd);
  }else if(arguments.length == 1 && arguments[0]._className != "Array"){
    ys = arguments[0]; yd = ys2yd(ys);
  }else{
    yd = arguments; ys = yd2ys(yd);
  }
  if(yd.length > 6) throw new Error("Yuraru.Date: arguments.length is unnormal.");
  this._private = {};
  this._private.yd = yd;
  this._private.ys = ys;
  return this;
};
Yuraru.Date.prototype._className = "Yuraru.Date";
Yuraru.Date.prototype.getYd = function(){
  return this._private.yd;
};
Yuraru.Date.prototype.getYs = function(){
  return this._private.ys;
};
Yuraru.Date.prototype.setYd = function(yd){
  if(arguments.length != 1){
    yd = [arguments[0]];
    for(var i=1, l=arguments.length; i<l; i++)
      yd[i] = arguments[i];
  }
  if(yd._className != "Array") throw TypeError("Yuraru.Date.setYd(): The argument is not Array.");
  yd = yd.map(function(elm){return Number(elm);});
  this._private.yd = yd;
  this._private.ys = yd2ys(yd);
  return this;
};
Yuraru.Date.prototype.setYs = function(ys){
  if(ys._className != "Number") throw new TypeError("Yuraru.Date.setYs(): The argument is not Number.");
  ys = Math.floor(ys);
  this._private.ys = ys;
  this._private.yd = ys2yd(ys);
  return this;
};
Yuraru.Date.prototype.getUTC = function(){
  var d = yd2ud(this._private.yd);
  ++d[1];
  return d;
};
Yuraru.Date.prototype.getLocal = function(){
  var d = yd2ld(this._private.yd);
  ++d[1];
  return d;
};
Yuraru.Date.prototype.getJMT = function(){
  var d = ud2jmtd(yd2ud(this._private.yd));
  ++d[1];
  return d;
};
Yuraru.Date.prototype.toString = function(){
  return this._private.yd[0]+"-"+this._private.yd[1]+"-"+this._private.yd[2]+" "+this._private.yd[3]+":"+this._private.yd[4]+":"+this._private.yd[5];
};
Yuraru.Date.prototype.toDateString = function(){
  return this._private.yd[0]+"-"+this._private.yd[1]+"-"+this._private.yd[2];
};
Yuraru.Date.prototype.toTimeString = function(){
  return this._private.yd[3]+":"+this._private.yd[4]+":"+this._private.yd[5];
};
Yuraru.Date.prototype.toLocaleString = function(){
  return this._private.yd[0]+"年"+this._private.yd[1]+"月"+this._private.yd[2]+"日"+this._private.yd[3]+"刻"+this._private.yd[4]+"裂"+this._private.yd[5]+"瞬";
};
Yuraru.Date.prototype.toLocaleDateString = function(){
  return this._private.yd[0]+"年"+this._private.yd[1]+"月"+this._private.yd[2]+"日";
};
Yuraru.Date.prototype.toLocaleTimeString = function(){
  return this._private.yd[3]+"刻"+this._private.yd[4]+"裂"+this._private.yd[5]+"瞬";
};
Yuraru.Date.prototype.valueOf = function(){
  return this._private.ys;
};

(function(){
var format = function(d){for(var i=0; i<7; i++) d[i] = (d[i] ? d[i] : 0); return d;};
Yuraru.Date.util = {
  jmt2utc: function(jmtd){jmtd=format(jmtd); return jmtd2ud(jmtd);},
  jmt2local: function(jmtd){jmtd=format(jmtd); return jmtd2ud(ud2ld(jmtd));},
  jmt2yuraru: function(jmtd){jmtd=format(jmtd); return ud2yd(jmtd2ud(jmtd));},
  utc2jmt: function(ud){ud=format(ud); return ud2jmtd(ud);},
  utc2local: function(ud){ud=format(ud); return ud2ld(ud);},
  utc2yuraru: function(ud){ud=format(ud); return ud2yd(ud);},
  local2jmt: function(ld){ud=format(ld); return ld2ud(ud2jmtd(ld));},
  local2utc: function(ld){ld=format(ld); return ld2ud(ld);},
  local2yuraru: function(ld){ld=format(ld); return ld2yd(ld);},
  yuraru2jmt: function(yd){yd=format(yd); return ud2jmtd(yd2ud(yd));},
  yuraru2utc: function(yd){yd=format(yd); return yd2ud(yd);},
  yuraru2local: function(yd){yd=format(yd); return yd2ld(yd);}
};
})();

Yuraru.Date.kano = [
  ["嘘月","虚偽の月","gedo ru kano", "You are a fool!"],
  ["元月","始原の月","chirani ru kano"],
  ["炎月","火炎の月","shuru ru kano"],
  ["旱月","乾燥の月","kozare kano"],
  ["麥月","穀物の月","ifega kano"],
  ["知月","智慧の月","hozonreti kano"],
  ["風月","疾風の月","segokata ru kano"],
  ["氷月","氷雪の月","kihiisa ru kano"],
  ["中月","復活の月","riderumife kano"],
  ["無月","無名の月","neyuginare kano"],
  ["水月","清水の月","riyon ru kano"],
  ["花月","黒陽花の月","hamyurufaria kano"],
  ["潤月","濕氣の月","bejerare kano"],
  ["雨月","慈雨の月","eruso ru kano"],
  ["嵐月","大嵐の月","hazanagae ru kano"],
  ["極月","終末の月","adani ru kano"]
];

})();

ついでにHTMLのコードも。keyword:uupaa.jsを使っています。

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
<!--
 * ユーラル暦ゐ゛ゅーあー ver 0.1
 * project name: Yuraru for Gardea
 * project leader: Haruna Tachibana
 *                   tachibana.haruna@gmail.com
 *                   http://c4se.sakura.ne.jp/ta_index.html
 * author: Nemu Inoue
 *           utakata.c4se@gmail.com
 *           http://c4se.sakura.ne.jp/ne_index.html
 * license: c4seFCL 0.1
 -->

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta http-equiv="Content-Style-Type" content="text/css"/>
  <meta http-equiv="Content-Script-Type" content="application/javascript"/>
  <link rel="icon" href="img_c4se_48.ico" type="image/vnd.microsoft.icon">
  <link rel="alternate" type="application/rss+xml" title="Feed c4se" href="http://feeds.feedburner.jp/c4se"/>
  <link rel="stylesheet" href="ta_def.css"/>
  <style>
  .title{
    text-align:center;
    font-size:x-large;
  }
  #conv{
    position:relative;
    width:;height:9em;
    background:#c0ffee;
    border:1px solid #000;
  }
  #jmttitle{position:absolute;top:0.5em;left:0.5em;width:100%;height:2em;}
  #utctitle{position:absolute;top:2.5em;left:0.5em;width:100%;height:2em;}
  #localtitle{position:absolute;top:4.5em;left:0.5em;width:100%;height:2em;}
  #yurarutitle{position:absolute;top:6.5em;left:0.5em;width:100%;height:2em;}
  #jmtform{position:absolute;top:0.5em;right:0;left:5em;width:;height:2em;height:1.5em;}
  #utcform{position:absolute;top:2.5em;right:0;left:5em;width:;height:2em;height:1.5em;}
  #localform{position:absolute;top:4.5em;right:0;left:5em;width:;height:2em;height:1.5em;}
  #yuraruform{position:absolute;top:6.5em;right:0;left:5em;width:;height:2em;height:1.5em;}
  input{
    background:#fff;
    color:#000;
    font-weight:normal;
  }
  </style>
  <script>
  Array.prototype.clone = function(){
    var a = new Array();
    for(var i=0; i<this.length; i++){
      if(this[i]._className != "Array")
        a[a.length] = this[i];
      else
        a[a.length] = this[i].clone();
    }
    return a;
  };
  </script>
  <script src="bi_laboratory/lib/uupaa.js"></script>
  <script src="ta_YuraruReki.js"></script>
  <script>
  var ff = {};
  ff.yd = new Yuraru.Date();
  uu.ready(function(){
    var fj = ff.fj = uu.id("jmtform");
    var fu = ff.fu = uu.id("utcform");
    var fl = ff.fl = uu.id("localform");
    var fy = ff.fy = uu.id("yuraruform");
    [fj.jmtyear.value, fj.jmtmonth.value, fj.jmtdate.value, fj.jmthours.value, fj.jmtminutes.value] = ff.yd.getJMT();
    [fu.utcyear.value, fu.utcmonth.value, fu.utcdate.value, fu.utchours.value, fu.utcminutes.value] = ff.yd.getUTC();
    [fl.localyear.value, fl.localmonth.value, fl.localdate.value, fl.localhours.value, fl.localminutes.value] = ff.yd.getLocal();
    [fy.yurarunen.value, fy.yurarutsuki.value, fy.yuraruhi.value, fy.yurarukoku.value, fy.yuraruretsu.value] = ff.yd.getYd();
  });
  var offsetString = (function(offset){
    offset = -offset;
    var s = "";
    if(offset < 0){s += "-"; offset = -offset;}
    else s += "+";
    var of = [Math.floor(offset/60), offset%60];
    if(of[0] < 10) s += "0" + of[0] + ":";
    else s += of[0] + ":";
    if(of[1] < 10) s += "0" + of[1];
    else s += of[1];
    return s;
  })((new Date()).getTimezoneOffset());
  var localToLocaleString = function(ld){
    return ld[0]+"年"+ld[1]+"月"+ld[2]+"日"+ld[3]+"時"+ld[4]+"分"+ld[5]+"秒 GMT"+offsetString;
  };
   ff.blurChange = function(s){
    var fj = ff.fj; var fu = ff.fu; var fl = ff.fl; var fy = ff.fy;
    var jmtd = [fj.jmtyear.value, fj.jmtmonth.value, fj.jmtdate.value, fj.jmthours.value, fj.jmtminutes.value, 0, 0];
    var ud = [fu.utcyear.value, fu.utcmonth.value, fu.utcdate.value, fu.utchours.value, fu.utcminutes.value, 0, 0];
    var ld = [fl.localyear.value, fl.localmonth.value, fl.localdate.value, fl.localhours.value, fl.localminutes.value, 0, 0];
    var yd = [fy.yurarunen.value, fy.yurarutsuki.value, fy.yuraruhi.value, fy.yurarukoku.value, fy.yuraruretsu.value, 0];
    var sA_to_nA = function(a){
      for(var i=0, l=a.length; i<l; i++)
        a[i] = Number(a[i]);
      return a;
    };
    jmtd = sA_to_nA(jmtd); ud = sA_to_nA(ud); ld = sA_to_nA(ld); yd = sA_to_nA(yd);
    var util = Yuraru.Date.util;
    /*switch(s){
      case "j":
        [fu.utcyear.value, fu.utcmonth.value, fu.utcdate.value, fu.utchours.value, fu.utcminutes.value] = util.jmt2utc(jmtd);
        [fl.localyear.value, fl.localmonth.value, fl.localdate.value, fl.localhours.value, fl.localminutes.value] = util.jmt2local(jmtd);
        yd = [fy.yurarunen.value, fy.yurarutsuki.value, fy.yuraruhi.value, fy.yurarukoku.value, fy.yuraruretsu.value] = util.jmt2yuraru(jmtd);
        break;
      case "u":
        [fj.jmtyear.value, fj.jmtmonth.value, fj.jmtdate.value, fj.jmthours.value, fj.jmtminutes.value] = util.utc2jmt(ud);
        [fl.localyear.value, fl.localmonth.value, fl.localdate.value, fl.localhours.value, fl.localminutes.value] = util.utc2local(ud);
        yd = [fy.yurarunen.value, fy.yurarutsuki.value, fy.yuraruhi.value, fy.yurarukoku.value, fy.yuraruretsu.value] = util.utc2yuraru(ud);
        break;
      case "l":
        [fj.jmtyear.value, fj.jmtmonth.value, fj.jmtdate.value, fj.jmthours.value, fj.jmtminutes.value] = util.local2jmt(ld);
        [fu.utcyear.value, fu.utcmonth.value, fu.utcdate.value, fu.utchours.value, fu.utcminutes.value] = util.local2utc(ld);
        yd = [fy.yurarunen.value, fy.yurarutsuki.value, fy.yuraruhi.value, fy.yurarukoku.value, fy.yuraruretsu.value] = util.local2yuraru(ld);
        break;
      case "y":
        [fj.jmtyear.value, fj.jmtmonth.value, fj.jmtdate.value, fj.jmthours.value, fj.jmtminutes.value] = util.yuraru2jmt(yd);
        [fu.utcyear.value, fu.utcmonth.value, fu.utcdate.value, fu.utchours.value, fu.utcminutes.value] = util.yuraru2utc(yd);
        yd = [fl.localyear.value, fl.localmonth.value, fl.localdate.value, fl.localhours.value, fl.localminutes.value] = util.yuraru2local(yd);
        break;
    }*/
    switch(s){
      case "j":
        --jmtd[1];
        yd = util.jmt2yuraru(jmtd);
        break;
      case "u":
        --ud[1];
        yd = util.utc2yuraru(ud);
        break;
      case "l":
        --ld[1];
        yd = util.local2yuraru(ld);
        break;
      case "y":
        break;
    }
    ff.yd.setYd(yd);
    [fj.jmtyear.value, fj.jmtmonth.value, fj.jmtdate.value, fj.jmthours.value, fj.jmtminutes.value] = ff.yd.getJMT();
    [fu.utcyear.value, fu.utcmonth.value, fu.utcdate.value, fu.utchours.value, fu.utcminutes.value] = ff.yd.getUTC();
    [fl.localyear.value, fl.localmonth.value, fl.localdate.value, fl.localhours.value, fl.localminutes.value] = ff.yd.getLocal();
    [fy.yurarunen.value, fy.yurarutsuki.value, fy.yuraruhi.value, fy.yurarukoku.value, fy.yuraruretsu.value] = ff.yd.getYd();
    return yd;
  };
  uu.ready(function(){
    var fj = ff.fj; var fu = ff.fu; var fl = ff.fl; var fy = ff.fy;
    fj.jmtyear.onblur = fj.jmtmonth.onblur = fj.jmtdate.onblur = fj.jmthours.onblur = fj.jmtminutes.onblur = function(){ff.blurChange("j");};
    fu.utcyear.onblur = fu.utcmonth.onblur = fu.utcdate.onblur = fu.utchours.onblur = fu.utcminutes.onblur = function(){ff.blurChange("u");};
    fl.localyear.onblur = fl.localmonth.onblur = fl.localdate.onblur = fl.localhours.onblur = fl.localminutes.onblur = function(){ff.blurChange("l");};
    fy.yurarunen.onblur = fy.yurarutsuki.onblur = fy.yuraruhi.onblur = fy.yurarukoku.onblur = fy.yuraruretsu.onblur = function(){ff.blurChange("y");};
  });
  </script>
  <title>YuraruDate 橘榛名 c4se</title>
</head>

<body>
<div class="title">ユーラル&#26310;(イリア紀元)</div>
<div>
  <div style="height:5em;">
    此処は何時開かれたか:<br/>
    <script>document.write("&nbsp;"+ff.yd.toLocaleString());</script><br/>
    <script>document.write("&nbsp;"+localToLocaleString(ff.yd.getLocal()));</script><br/>
  </div>
  <div id="conv">
    <div id="jmt">
      <div id="jmttitle">JMT: </div>
      <form id="jmtform">
        <input id="jmtyear" size="5"/><input id="jmtmonth" size="3"/><input id="jmtdate" size="3"/><input id="jmthours" size="3"/><input id="jmtminutes" size="3"/>分 GMT+09:00
      </form>
    </div>
    <div id="utc">
      <div id="utctitle">UTC: </div>
      <form id="utcform">
        <input id="utcyear" size="5"/><input id="utcmonth" size="3"/><input id="utcdate" size="3"/><input id="utchours" size="3"/><input id="utcminutes" size="3"/></form>
    </div>
    <div id="local">
      <div id="localtitle">Local: </div>
      <form id="localform">
        <input id="localyear" size="5"/><input id="localmonth" size="3"/><input id="localdate" size="3"/><input id="localhours" size="3"/><input id="localminutes" size="3"/>分
        GMT<script>document.write(offsetString);</script>
      </form>
    </div>
    <div id="yuraru">
      <div id="yurarutitle">Yuraru: </div>
      <form id="yuraruform">
        <input id="yurarunen" size="5"/><input id="yurarutsuki" size="3"/><input id="yuraruhi" size="3"/><input id="yurarukoku" size="3"/><input id="yuraruretsu" size="3"/></form>
    </div>
  </div>
</div>
<div>
  <iframe src="ta_yu_yurarureki.txt"
          style="color:#000;
                 background:#fff;
                 font-size:10pt;
                 width:80%;
                 height:15em;"></iframe>
</div>
<div><br/>
  <a href="ta_index.html">- ユーラルのある世界…兩河世界の記述 -</a>
</div>

<div id="bottomLogo">
  <hr/>
  <a href="index.html" title="c4seトップ">c4se</a>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-2149134-4");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</body>

</html>