svnno****@sourc*****
svnno****@sourc*****
2009年 6月 14日 (日) 22:36:42 JST
Revision: 1224 http://svn.sourceforge.jp/view?root=sie&view=rev&rev=1224 Author: dhrname Date: 2009-06-14 22:36:42 +0900 (Sun, 14 Jun 2009) Log Message: ----------- DateオブジェクトにsetClockValueメソッドを追加 Modified Paths: -------------- branches/05x/051/sie.js Modified: branches/05x/051/sie.js =================================================================== --- branches/05x/051/sie.js 2009-06-11 13:54:05 UTC (rev 1223) +++ branches/05x/051/sie.js 2009-06-14 13:36:42 UTC (rev 1224) @@ -1822,6 +1822,35 @@ } catch(e) {stlog.add(e,17155);} } +//setClockValueメソッド。同期させるSMIL言語に使う +Date.prototype.setClockValue = function(str) { + var n = str.indexOf(":"), d = 0, h = 0, min = 0, s = 0; + if (n === -1) { //単位つきTimecount-Valueならば + d = parseFloat(str); + if (isNaN(d)) { + throw new Error("文法エラーです"); + } + var tani = str.match(/[a-z]+/); + tani = tani ? tani : "s"; + d *= this._tani[tani]; + } else { + if (n !== str.lastIndexOf(":")) { //Full-clock-Valueならば + var fullClock = str.match(/(\d+)\:(\d\d)\:([\.\d]+)/); + h = RegExp.$1; min = RegExp.$2; s = RegExp.$3; + } else { + partialClock = str.match(/(\d\d)\:([\.\d]+)/); + min = RegExp.$1; s = RegExp.$2; + } + d = parseInt(h)*3600000 + parseInt(min)*6000 + parseFloat(s)*1000; + } + this.clockValue = d; +} +Date.prototype._tani = {"h":3600000, "min":6000, "s":1000, "ms":1}; + +var ddnd = new Date(); +ddnd.setClockValue("40min"); +alert(ddnd.clockValue); + function utf16( /*string*/ s) { return unescape(s); }