[Glass] Kind of _asDaysFrom1970 that answers negative numbers?

Mariano Martinez Peck via Glass glass at lists.gemtalksystems.com
Thu Feb 23 12:30:32 PST 2017


Hi guys,

I am using  _asDaysFrom1970 to convert Smalltalk dates to Javascript dates
that I pass via JSON (as milliseconds since 1907 epoch) to a chart library.

The problem is that I need this even for dates before 1970. I checked that:

1) JS can accept this:

new Date(-100000000)
->  Tue Dec 30 1969 17:13:20 GMT-0300 (ART)

2) The chart lib  I use, I can also specify this:

   data: [
            [-1394104654000, 42],
        ]


So... my remaining problem is that I would like a primitive-based (for
performance) like _asDaysFrom1970 but that knows how to answer negative
numbers for those dates prior to 1970.

Do we have already something like this? Could this be added?

Below is the method in question.

Thanks in advance,

Best regards.


---------------------


_asDaysFrom1970
  "Convert the receiver to a SmallInteger representing the number of days
since
January 1, 1970."

  "Primitive does not support instances which represent a date before 1970."

  <primitive: 540>
  ^ self _primitiveFailed: #'_asDaysFrom1970'




-- 
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20170223/6508696b/attachment.html>


More information about the Glass mailing list