These are chat archives for opal/opal

14th
Oct 2016
Serzh
@Serzhenka
Oct 14 2016 10:34

@/all Hello everyone!
I'm coming from Hyperloop)

Did anyone can help with converting string (datetime type from db as string in Opal) to datetime Object in Components (React-rb/Hyperloop)?

Can’t find any doc to converting and formating my string from db..
Looking for Opal now.. May be i need to require some additional?

So here is the coming string:
2017-10-13T14:55:56.595Z

after that need format like: date.now.strftime('%a, %e %b %Y %H:%M') as example.
Thanks for the help..

Ilya Bylich
@iliabylich
Oct 14 2016 11:00
@Serzhenka Which version of Opal are you using? On master this should work - Date.wrap(new Date('2017-10-13T14:55:56.595Z')).strftime('%a, %e %b %Y %H:%M')
There's a "`" char between Date.wrap( and new Date
Serzh
@Serzhenka
Oct 14 2016 11:01
@iliabylich VERSION = '0.10.2'
Ilya Bylich
@iliabylich
Oct 14 2016 11:04
Does it work for you?
Serzh
@Serzhenka
Oct 14 2016 11:07
Just, 1 minute please, trying now
Ilya Bylich
@iliabylich
Oct 14 2016 11:17
@Serzhenka If you need to quickly check some opal stuff use opal-repl
Serzh
@Serzhenka
Oct 14 2016 11:19
@iliabylich hmm:
undefined method 'wrap' for Date wrap: undefined method 'wrap' for Date
*in browser console
Date.wrap(`Date('2017-10-13T14:55:56.595Z')`).strftime('%a, %e %b %Y %H:%M')
Ilya Bylich
@iliabylich
Oct 14 2016 11:22
Date('2017-10-13T14:55:56.595Z') - should be new Date('2017-10-13T14:55:56.595Z')
Serzh
@Serzhenka
Oct 14 2016 11:25

Yes, now fix string to:

Date.wrap(`new Date('2017-10-13T14:55:56.595Z')`).strftime('%a, %e %b %Y %H:%M’)

But the same error.

Aha i see in gist require ‘date'
Serzh
@Serzhenka
Oct 14 2016 11:44
@iliabylich Did i need any additional istall gems for require ‘date’?
Ilya Bylich
@iliabylich
Oct 14 2016 11:53
Serzh
@Serzhenka
Oct 14 2016 12:00

@catmando May be you can tell more info about calling same method in Components of reactrb?

Date.wrap(`new Date('2017-10-13T14:55:56.595Z')`).strftime('%a, %e %b %Y %H:%M’)

in browser console is: class_methods.rb:21Exception raised while rendering #<Components::SideUserItem:0x93e>: undefined method 'wrap' for Date wrap: undefined method 'wrap' for Date

Opal VERSION = '0.10.2'

But in clean Opal it’s worked, thanks to @iliabylich for info..
Serzh
@Serzhenka
Oct 14 2016 14:19
Question is closed with help @iliabylich, thanks!