SVN で最新の Datejs リリースを使用していることを確認してください。http://www.datejs.com/svn/。
プロパティを取得することもでき.days
ます。
例
var a = Date.today();
var b = Date.today().next().friday();
var ts = new TimeSpan(b - a);
console.log(ts.days);
編集
TimeSpan
クラスとともに、Datejs の time.js パッケージ内には、TimePeriod
2 つの Date の違いをさらに分割して と を含めるクラスが.months
あり.years
ます。
ランダムに生成されたyear
値を使用した完全なサンプルを次に示します。2 つのconsole.log
値は同じである必要があります。
例
var random = Math.floor(Math.random()*12);
var a = Date.today();
var b = Date.today().add(random).years();
var tp = new TimePeriod(a, b);
console.log('random', random);
console.log('years', tp.years);
お役に立てれば。