Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Date marshalling

$
0
0
Hi guillaume86,

You can add valueOf as an extension method:
publicstaticclass DateTimeExtensions {
    publicstaticdouble valueOf(this DateTime value) {
        return value.Ticks;
    }
}
and then:
engine.AddHostType(typeof(DateTime));
engine.AddHostType(typeof(DateTimeExtensions));
Console.WriteLine(engine.Evaluate("a = DateTime.Now; b = DateTime.Now; b >= a"));
Note that this only works on V8, as JScript doesn't follow the valueOf protocol for host objects.

Good luck!

Viewing all articles
Browse latest Browse all 2297

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>