#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Thu, 15 Mar 2018 23:05:55 +0100
changeset 22613 875197e3bb08
parent 22612 03d9c323a352
child 22614 369da8fe40ea
#FEATURE by cg class: Timestamp preparation for more resolution (added picoSecond instvar) class definition added: #picoseconds class: Timestamp class comment/format in: #documentation
Timestamp.st
--- a/Timestamp.st	Thu Mar 15 22:45:19 2018 +0100
+++ b/Timestamp.st	Thu Mar 15 23:05:55 2018 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1989 by Claus Gittinger
 	      All Rights Reserved
@@ -14,7 +16,7 @@
 "{ NameSpace: Smalltalk }"
 
 AbstractTime subclass:#Timestamp
-	instanceVariableNames:'osTime'
+	instanceVariableNames:'osTime picoSeconds'
 	classVariableNames:'Epoch MaxOSTime MinOSTime TimeZoneInfo'
 	poolDictionaries:''
 	category:'Magnitude-Time'
@@ -75,8 +77,8 @@
     The implementation of this class is not the same as in ST-80
     (which represents the time as seconds from Jan 1., 1901).
 
-    This class should not be confused with Time (which only represents the
-    time within one day). Time instances cannot be used to compare times across midnight;
+    This class should not be confused with Time (which only represents the time within one day). 
+    Time instances cannot be used to compare times across midnight;
     instances of Timestamp can.
 
     Notice: this class was once called AbsoluteTime. Einstein told us in 1905, that talking
@@ -86,13 +88,18 @@
 
     Also Note:
         On UNIX, osTime can only hold dates between 1970-01-01T00:00:00Z and 2038-01-19T03:14:07Z
-        However, timestamp instances can now hold negative osTime values (which are timestamps
-        before 1.1.1970 and greater than 4294967295 (2^32-1) for timestamps after 2038-01-19.
+        However, timestamp instances can hold negative osTime values (which are timestamps
+        before 1.1.1970 and also osTimes greater than 4294967295 (2^32-1) for timestamps after 2038-01-19.
 
         For dates before 1582 (when calendars were changed from Julian to Gregorian),
         the so called 'proleptic gregorian calendar' is used. This assumes leap years to continue in
         the past as if a gregorian calendar was used. Thus, 0000 is considered a leap year.
 
+        And, the additional instance variable picoSeconds can be used to add more
+        resolution. If non-nil, it holds additional picoseconds to be added to the millisecond osTime.
+        Although, not all OSs give us that detail when asking for the current time,
+        the picos can still be used in physical computations.
+
     [author:]
         Claus Gittinger
 
@@ -1563,7 +1570,7 @@
             'IDLW' -720 false          "/ international date line west
             'IDLE'  720 false          "/ international date line east
 
-            'MEZ'   60  false           "/ mittel europäische Zeit /  central european (german)
+            'MEZ'   60  false           "/ mittel europäische Zeit /  central european (german)
             'MESZ'  120 true            "/ central european summer (german)
             'WESZ'  60  true            "/ west european summer (german)
 
@@ -1911,6 +1918,16 @@
     osTime := aTime.
 !
 
+picoseconds
+    "return the picoseconds (0..1000*1000*1000)"
+
+    ^ picoSeconds ? 0.
+
+    "
+     Timestamp now picoseconds
+    "
+!
+
 second
     "return the second (0..59).
      ST-80 Timestamp compatibility (I'd prefer the name #seconds, for Time compatibility)."