Time.st
changeset 6467 f200ac48f2a8
parent 6165 0ac589c3d92a
child 6624 886265eff14c
equal deleted inserted replaced
6466:ae28dd895a58 6467:f200ac48f2a8
    87      Time fromSeconds:0     
    87      Time fromSeconds:0     
    88      Time fromSeconds:3675     
    88      Time fromSeconds:3675     
    89      Time fromSeconds:36000     
    89      Time fromSeconds:36000     
    90      Time fromSeconds:72000     
    90      Time fromSeconds:72000     
    91      Time fromSeconds:96000      
    91      Time fromSeconds:96000      
       
    92      Time fromSeconds:360000      
    92     "
    93     "
    93 
    94 
    94     "Modified: 8.10.1996 / 19:32:11 / cg"
    95     "Modified: 8.10.1996 / 19:32:11 / cg"
    95 
       
    96 
       
    97 
       
    98 !
    96 !
    99 
    97 
   100 hour:h minutes:m seconds:s
    98 hour:h minutes:m seconds:s
   101     "return an instance of Time representing the given time.
    99     "return an instance of Time representing the given time.
   102      See also Time now / Date today / AbsoluteTime now.
   100      See also Time now / Date today / AbsoluteTime now.
   246 
   244 
   247 intervalString
   245 intervalString
   248     "Treat the time as a difference.  
   246     "Treat the time as a difference.  
   249      Give it in hours and minutes with two digits of accuracy."
   247      Give it in hours and minutes with two digits of accuracy."
   250 
   248 
   251     |hours minutes seconds hh mm ss |
   249     |hours minutes seconds hh mm ss s|
   252 
   250 
   253     hours := self hours.
   251     hours := self hours.
   254     minutes := self minutes.
   252     minutes := self minutes.
   255     seconds := self seconds.
   253     seconds := self seconds.
   256     hh := hours = 0   ifTrue: [''] ifFalse: [' ', hours printString, ' hours'].
   254 
   257     mm := minutes = 0 ifTrue: [''] ifFalse: [' ', minutes printString, ' minutes'].
   255     hours = 0   
   258     ss := seconds = 0 ifTrue: [''] ifFalse: [' ', seconds printString, ' seconds'].
   256         ifTrue: [hh := ''] 
       
   257         ifFalse: [
       
   258             hh := hours printString, ' hour'.
       
   259             hours > 1 ifTrue:[
       
   260                 hh := hh , 's'
       
   261             ]
       
   262         ].
       
   263     minutes = 0 
       
   264         ifTrue: [mm := ''] 
       
   265         ifFalse: [
       
   266             mm := minutes printString, ' minute'.
       
   267             minutes > 1 ifTrue:[
       
   268                 mm := mm , 's'
       
   269             ]
       
   270         ].
       
   271     seconds = 0 
       
   272         ifTrue: [ss := ''] 
       
   273         ifFalse: [
       
   274             ss := seconds printString, ' second'.
       
   275             seconds > 1 ifTrue:[
       
   276                 ss := ss , 's'
       
   277             ]
       
   278         ].
       
   279 
       
   280     "/ do not show seconds, if hours are there
   259     hh size > 0 ifTrue: [ss := ''].
   281     hh size > 0 ifTrue: [ss := ''].
   260     ^ hh, mm, ss
   282 
   261 
   283     s := hh.
   262     "
   284     hh notEmpty ifTrue:[
   263      (Time fromSeconds:3600) intervalString
   285         hh := hh , ' '
   264      (Time fromSeconds:3605) intervalString
   286     ].
   265      (Time fromSeconds:5) intervalString  
   287     s := s , mm.
       
   288     mm notEmpty ifTrue:[
       
   289         mm := mm , ' '
       
   290     ].
       
   291     ^ s , ss
       
   292 
       
   293     "
       
   294      (Time fromSeconds:360000) intervalString      
       
   295      (Time fromSeconds:3600) intervalString    
       
   296      (Time fromSeconds:3605) intervalString  
       
   297      (Time fromSeconds:3700) intervalString  
       
   298      (Time fromSeconds:5) intervalString    
   266      (Time fromSeconds:65) intervalString   
   299      (Time fromSeconds:65) intervalString   
   267     "
   300     "
   268 !
   301 !
   269 
   302 
   270 print24:prnt24Format showSeconds:doSeconds on:aStream
   303 print24:prnt24Format showSeconds:doSeconds on:aStream
   626 ! !
   659 ! !
   627 
   660 
   628 !Time class methodsFor:'documentation'!
   661 !Time class methodsFor:'documentation'!
   629 
   662 
   630 version
   663 version
   631     ^ '$Header: /cvs/stx/stx/libbasic/Time.st,v 1.52 2001-11-08 16:07:36 md Exp $'
   664     ^ '$Header: /cvs/stx/stx/libbasic/Time.st,v 1.53 2002-03-18 11:01:03 cg Exp $'
   632 ! !
   665 ! !