Class.st
changeset 24114 9d503e21996b
parent 24009 b32acf21c0e9
child 24119 458b88178b7c
--- a/Class.st	Wed May 08 12:42:34 2019 +0200
+++ b/Class.st	Wed May 08 12:45:12 2019 +0200
@@ -505,7 +505,6 @@
 ! !
 
 
-
 !Class methodsFor:'Compatibility-Dolphin'!
 
 defaultCategoryForDolphinClasses
@@ -5028,6 +5027,67 @@
     "Modified: / 21-11-2017 / 18:34:08 / cg"
 !
 
+revisionDate
+    "return the revision-Date of the class as date or nil.
+     This is extracted from the version string."
+
+    |info dateString date|
+
+    info := self revisionInfo.
+    info isNil ifTrue:[^ nil].
+    
+    dateString := info date.
+    
+    ('[12][7890][0-9][0-9]/[0-1][0-9]/[0-3][0-9]' match:dateString) ifTrue:[
+        date := Date readFrom:dateString format:'%y/%m/%d'.
+    ] ifFalse:[
+        ('[12][7890][0-9][0-9]-[0-1][0-9]-[0-3][0-9]' match:dateString) ifTrue:[
+            date := Date readFrom:dateString format:'%y-%m-%d'.
+        ] ifFalse:[
+            self halt:'unrecognized date'.
+            ^ nil
+        ].    
+    ].    
+
+    ^ date
+
+    "
+     Object revisionDate
+    "
+    
+    "verify readability:
+    
+     Smalltalk allClassesDo:[:cls | (cls revisionDate)]
+
+     Smalltalk allClasses 
+        select:[:cls | 
+                    (cls revisionDate isNil) 
+                    and:[cls isLoaded
+                    and:[cls isNameSpace not]]
+        ]
+
+     Smalltalk allClasses 
+        select:[:cls | cls isLoaded and:[cls isNameSpace not]]
+        thenCollect:[:cls | cls -> cls revisionDate]
+    "
+
+    "classes stable for more than 10 years:
+    
+     (Smalltalk allClasses 
+        select:[:cls | cls isLoaded and:[cls isPrivate not and:[cls isNameSpace not]]])
+        select:[:cls | cls revisionDate < (Timestamp now - (TimeDuration years:10))]
+    "
+
+    "classes changed within the last 2 days:
+
+     (Smalltalk allClasses 
+        select:[:cls | cls isLoaded and:[cls isPrivate not and:[cls isNameSpace not]]])
+        select:[:cls | cls revisionDate > (Timestamp now - 2 days)]
+    "
+
+    "Created: / 08-05-2019 / 12:12:21 / Claus Gittinger"
+!
+
 revisionDateString
     "return the revision-Date of the class as a string.
      This is extracted from the version string."
@@ -5051,28 +5111,34 @@
 revisionInfo
     "return an object filled with revision info.
      This extracts the relevant info from the revisionString.
+     For private classes, the revisionInfo of the owning class is returned.
      The revisionInfo contains all or a subset of:
-	binaryRevision - the revision upon which the binary of this class is based
-	revision       - the revision upon which the class is based logically
-			  (different, if a changed class was checked in, but not yet recompiled)
-	user           - the user who checked in the logical revision
-	date           - the date when the logical revision was checked in
-	time           - the time when the logical revision was checked in
-	fileName       - the classes source file name
-	repositoryPath - the classes source container
-    "
-
+        binaryRevision - the revision upon which the binary of this class is based
+        revision       - the revision upon which the class is based logically
+                          (different, if a changed class was checked in, but not yet recompiled)
+        user           - the user who checked in the logical revision
+        date           - the date when the logical revision was checked in (as string)
+        time           - the time when the logical revision was checked in (as string)
+        fileName       - the classes source file name
+        repositoryPath - the classes source container
+    "
+
+    self isPrivate ifTrue:[
+        ^ self owningClass revisionInfo
+    ].    
     ^ self revisionInfoOfManager:self sourceCodeManagerFromBinaryRevision
 
     "
      Object revisionString
      Object revisionInfo
      Image revisionInfo
+     Method::MethodWhoInfo revisionInfo
     "
 
     "Created: / 11-11-1995 / 14:27:20 / cg"
     "Modified: / 26-03-1997 / 00:13:17 / stefan"
     "Modified: / 19-04-2011 / 13:41:24 / cg"
+    "Modified (comment): / 08-05-2019 / 12:22:25 / Claus Gittinger"
 !
 
 revisionInfoOfManager:aSourceCodemanagerOrNil
@@ -5212,6 +5278,54 @@
     "Modified: / 13-02-2019 / 19:44:45 / Claus Gittinger"
 !
 
+revisionTimestamp
+    "return the revision-Date of the class as timestamp or nil.
+     This is extracted from the version string."
+
+    |info timeString time date|
+
+    info := self revisionInfo.
+    info isNil ifTrue:[^ nil].
+    
+    date := self revisionDate.
+    timeString := info time.
+    timeString notEmptyOrNil ifTrue:[
+        ('[0-2][0-9]:[0-5][0-9]:[0-5][0-9]' match:timeString) ifTrue:[
+            time := Time readFrom:timeString format:'%h:%m:%s'.
+        ] ifFalse:[    
+            ('[0-2][0-9]:[0-5][0-9]' match:timeString) ifTrue:[
+                time := Time readFrom:timeString format:'%h:%m'.
+            ] ifFalse:[
+                self halt:'unrecognized time'.
+            ].    
+        ].
+    ].
+    time isNil ifTrue:[^ date].
+    ^ Timestamp fromDate:date andTime:time
+
+    "
+     Object revisionTimestamp
+    "
+    
+    "verify readability:
+    
+     Smalltalk allClassesDo:[:cls | (cls revisionTimestamp)]
+ 
+     Smalltalk allClasses 
+        select:[:cls | 
+                    (cls revisionTimestamp isNil) 
+                    and:[cls isLoaded
+                    and:[cls isNameSpace not]]
+        ]
+
+     Smalltalk allClasses 
+        select:[:cls | cls isLoaded and:[cls isNameSpace not]]
+        thenCollect:[:cls | cls -> cls revisionTimestamp]
+    "
+
+    "Created: / 08-05-2019 / 12:33:24 / Claus Gittinger"
+!
+
 setBinaryRevision:aString
     "set the revision-ID.
      This should normally not be done in the running system, as the source-manager