Hi Jeff,
On 15 Jun 2020, at 09:08, Jeff Gray <jeff@rogerthedog.com> wrote:
Thanks Steph.
Running a similar experiment using ZTimestamp:
|ts1 ts2| ts1 := ZTimestamp now. tsNumber := ts1 asUnixTime. ts2 := ZTimestamp fromUnixTime: tsNumber. Transcript cr; show: ts1. Transcript cr; show: ts2.
I get the output: 2020-06-15T07:05:59Z 2020-06-15T07:05:59Z
That is because ZTimestamp, by design, has second precision. To come back to your original question, it is not so simple to represent a timestamp as a single number. This is typically done by computing the distance to a so called epoch (reference). And you have to take the desired precision into account. You could do something like | epoch now integer timestamp | epoch := DateAndTime year: 2000 month: 1 day: 1 hour: 0 minute: 0 second: 0 nanoSecond: 0 offset: Duration zero. now := DateAndTime now. integer := (now - epoch) asNanoSeconds. timestamp := epoch + integer nanoSeconds. This works, but loses the timezone offset. That is why most databases use a string representation. For example using the tool that Stéphane described. For example, P3, the PostgreSQL client uses the ISO 8601 format YYYY-MM-DDThh:mm:ss.s+ZZ:zz HTH, Sven