-
• #2
I think if you look at
new Date
you actually get an object. If you then do maths with that object, Date.valueOf gets called, which returns a time in milliseconds since 1970...>new Date() ={ "ms": 949363214047.21643066406 } >0+(new Date()) =949363248128.48754882812
So yes, the time returned by
SWstop
will be milliseconds.Hope that helps :)
-
• #4
>(new Date(-1000)).toString() ="Thu Jan 1 1970 00:00:-1 GMT+0000"
I've just filed a bug for this
-
• #5
What would the correct output be in this case? What does node do?
-00:00:01 ?
The output at the moment can put a - in the h, m or s leading slot
-
• #6
Let's discuss it in the bug rather than messing up @ClearMemory041063's thread :)
-
• #7
http://forum.espruino.com/conversations/286424/#comment12967777
Attached is an upgraded module timeobj.js and a project file testTimeObj.js.You're correct that new.Date is an object, so the duplications in the object has been removed.
I found one bug in my code in that months are numbered 0 to 11.
The format uses arrays. The 'm' produces the three letter month name.I tried using local modules today in a project directory, great so far.
Thanks for the comments and tips.
2 Attachments
This Object implements a Date and Time formatting methods and a stopwatch function.
TimeObj.js listing follows:
The output of the Testit()function as seen in the left pane of the WebIDE:
One question is about the elapsed time units. The value 14.58 seems a bit long for seconds. Perhaps it is milliseconds.
1 Attachment