-
• #2
Thanks - I think on normal Espruino boards it could be added just fine without too many issues with memory. There's actually an issue open for this here: https://github.com/espruino/Espruino/issues/504
I'll see what I can do - which board are you using?
-
• #3
Im using espruino Pico.
I'm glad there is an open issue for that
Thanks!
-
• #4
Ok, I just added the setters. If you get one of the travis builds from here: https://www.espruino.com/binaries/travis/master/
Then you should be able to use them - let me know if they work ok.
-
• #5
I've used this one https://www.espruino.com/binaries/travis/master/espruino_1v92.80_pico_1r3.bin
works like a charm!
_____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v92.80 Copyright 2016 G.Williams > >t = new Date; =Date { "ms": 949363217722.27758789062 } >t.toString(); ="Tue Feb 1 2000 00:00:17 GMT+0000" >t.setHours(10); =949399217722 >t.toString(); ="Tue Feb 1 2000 10:00:17 GMT+0000" >t.setMinutes(10); =949399817722 >t.toString(); ="Tue Feb 1 2000 10:10:17 GMT+0000" >t.setFullYear(2022); =1643710217722 >t.toString(); ="Tue Feb 1 2022 10:10:17 GMT+0000" >t.setDate(29); =1646129417722 >t.toString(); ="Tue Mar 1 2022 10:10:17 GMT+0000" >t.setMonth(4); =1651399817722 >t.toString(); ="Sun May 1 2022 10:10:17 GMT+0000" >
Thank you!
-
• #6
No problem! If you go for an even more recent build, you'll find that there's an
E.setTimeZone(..)
function (taking a timezone in hours) that might be interesting for you as well. -
• #7
Yup
E.setTimeZone(..)
is nice
anyway I'm on 1v92.86 and I see travis at 1v92.111 now, is there something new worth mentioning? ;)by the way, the new Date class with setters is amazing! it simplified my project a lot
-
• #8
Great! I don't think you'll gain much by updating at the moment, but you can always check:
the js Date object is marvelous
https://www.w3schools.com/jsref/jsref_obj_date.asp
but it's espruino implementation is very limited so far, to be specific, we can only read from the Date object once it has been created.
Im working on a time switch, I've been using date class all around, finding out that set-methods are not implemented made me (almost :P ) depressed
Extending espruino's Date class would be extremely beneficial:
1) easy, date, time manipulation - clocks, timers, time switches
2) clock module wouldn't be necessary
3) if it's about memory, we can add set-methods and remove some of these:
Let me know what do you think of it!