These are chat archives for opal/opal

8th
Aug 2015
David Boardman
@djboardman
Aug 08 2015 10:06
Hi I'm trying to do some date arithmetic e.g. Date.new + 1 but getting lhs.$+ is not a function in 0.9.0-dev. I've seen a lot of changes going on in 0.9.0-dev for dates and time so should was wondering if that's something that is coming?
Vais Salikhov
@vais
Aug 08 2015 11:19

@djboardman hmm, it looks like calling Date.new without arguments is broken (it does not default to today as Ruby does). Here's what I'm getting:

$ bundle exec opal -ve "require 'date'; p Date.new"
Opal v0.9.0.dev
NaN-NaN-NaN

But:

$ bundle exec opal -ve "require 'date'; d = Date.new(2015, 1, 1); p d; p d + 1"
Opal v0.9.0.dev
2015-01-01
2015-01-02

So, call it with args or use Date.today:

$ bundle exec opal -ve "require 'date'; d = Date.today; p d; p d + 1"
Opal v0.9.0.dev
2015-08-08
2015-08-09

I'll see if I can fix this today though, thanks for bringing it up!

Vais Salikhov
@vais
Aug 08 2015 11:26
Actually, I just learned thatDate.new is supposed to default to -4712-01-01 :wink2:
Benny Bach
@bebac
Aug 08 2015 11:36
If anyone is interested, I just got the the vienna specs running with opal-browser. The repository can be found here https://github.com/bebac/vienna.git it is on a branch called opal-browser. I have only made a very basic application, so there might be some issues that haven't surfaced yet.
Elia Schito
@elia
Aug 08 2015 11:59
@vais 😳 TMYK
@bebac cool stuff!