Login
000-075-time.s2 at [b7046bf39b]
Login

File bindings/s2/unit2/000-075-time.s2 artifact 9cde80b3ed part of check-in b7046bf39b



scope {
    const tm = Fossil.time;
    var n = tm.now();
    var j = tm.unixToJulian(n);
    //print(n, tm.julianToUnix(j));
    //assert n === tm.julianToUnix(j) /* sometimes fails on rounding errors! Soo.... */;
    0.prototype.'operator=~' = proc(r){
        affirm 'integer' === typename r;
        return (this===r) || (this===(r-1)) || (this===(r+1));
    };
    assert n =~ tm.julianToUnix(j) /* round-trip sometime rounds badly, so we check for a +/-1 match */;
    unset n.prototype.'operator=~' /* avoid polluting downstream script code */;
    assert 19 === tm.julianToISO8601(j).length() /* w/o ms */;
    assert 23 === tm.julianToISO8601(j,true).length() /* w/ ms */;
}