Time.st
changeset 13213 d37c29bad3da
parent 12829 2fb56fae7300
child 13235 b33c7b351a11
equal deleted inserted replaced
13212:e75edfda9b2e 13213:d37c29bad3da
   247     "Modified: 8.10.1996 / 19:32:11 / cg"
   247     "Modified: 8.10.1996 / 19:32:11 / cg"
   248 ! !
   248 ! !
   249 
   249 
   250 !Time class methodsFor:'format strings'!
   250 !Time class methodsFor:'format strings'!
   251 
   251 
       
   252 defaultFormatString
       
   253     LanguageTerritory == #us ifTrue:[
       
   254         ^ self formatString12us
       
   255     ] ifFalse:[
       
   256         ^ self formatString24
       
   257     ]
       
   258 
       
   259     "Created: / 16-01-2011 / 11:23:36 / cg"
       
   260 !
       
   261 
   252 formatString12us
   262 formatString12us
   253     "return the format string used to format US times (and other areas)"
   263     "return the format string used to format US times (and other areas)"
   254 
   264 
   255     ^ '%u:%m:%s %A'
   265     ^ '%u:%m:%s %A'
   256 !
   266 !
   258 formatString24
   268 formatString24
   259     "return the format string used to format non US times"
   269     "return the format string used to format non US times"
   260 
   270 
   261     ^ '%h:%m:%s'
   271     ^ '%h:%m:%s'
   262 ! !
   272 ! !
       
   273 
   263 
   274 
   264 !Time methodsFor:'Compatibility-Squeak'!
   275 !Time methodsFor:'Compatibility-Squeak'!
   265 
   276 
   266 intervalString
   277 intervalString
   267     "Treat the time as a difference.  
   278     "Treat the time as a difference.  
   458 
   469 
   459     ^ timeEncoding
   470     ^ timeEncoding
   460 ! !
   471 ! !
   461 
   472 
   462 !Time methodsFor:'converting'!
   473 !Time methodsFor:'converting'!
   463 
       
   464 asNative
       
   465 	#swAdded.
       
   466 	^self
       
   467 !
       
   468 
   474 
   469 asSeconds
   475 asSeconds
   470     "return the number of seconds elapsed since midnight"
   476     "return the number of seconds elapsed since midnight"
   471 
   477 
   472     ^ self getSeconds
   478     ^ self getSeconds
   592 
   598 
   593      Format is hh:mm:ss either in 12-hour or 24-hour format.
   599      Format is hh:mm:ss either in 12-hour or 24-hour format.
   594      depending on the setting of LanguageTerritory.
   600      depending on the setting of LanguageTerritory.
   595      I dont know what ST-80 does here (12-hour format ?)"
   601      I dont know what ST-80 does here (12-hour format ?)"
   596 
   602 
   597     LanguageTerritory == #us ifTrue:[
   603     ^ self
   598         self print12HourFormatOn:aStream
   604         printOn:aStream 
   599     ] ifFalse:[
   605         format:(self class defaultFormatString)               
   600         self print24HourFormatOn:aStream
       
   601     ]
       
   602 
   606 
   603     "
   607     "
   604      Time now printOn:Transcript. Transcript cr
   608      Time now printOn:Transcript. Transcript cr
   605     "
   609     "
   606 
   610 
   607     "Modified: 22.2.1996 / 16:58:30 / cg"
   611     "Modified: / 16-01-2011 / 11:27:24 / cg"
   608 !
   612 !
   609 
   613 
   610 printString12HourFormat
   614 printString12HourFormat
   611     "return a printed representation in 12 hour format"
   615     "return a printed representation in 12 hour format"
   612 
   616 
   709      and should not be used outside."
   713      and should not be used outside."
   710 
   714 
   711     timeEncoding := encoding
   715     timeEncoding := encoding
   712 ! !
   716 ! !
   713 
   717 
       
   718 
   714 !Time class methodsFor:'documentation'!
   719 !Time class methodsFor:'documentation'!
   715 
   720 
   716 version
   721 version
   717     ^ '$Header: /cvs/stx/stx/libbasic/Time.st,v 1.87 2010-03-31 09:39:45 stefan Exp $'
   722     ^ '$Header: /cvs/stx/stx/libbasic/Time.st,v 1.88 2011-01-16 10:28:01 cg Exp $'
   718 !
   723 !
   719 
   724 
   720 version_CVS
   725 version_CVS
   721     ^ '$Header: /cvs/stx/stx/libbasic/Time.st,v 1.87 2010-03-31 09:39:45 stefan Exp $'
   726     ^ '$Header: /cvs/stx/stx/libbasic/Time.st,v 1.88 2011-01-16 10:28:01 cg Exp $'
   722 ! !
   727 ! !