Timestamp.st
branchjv
changeset 17847 62aa54f44969
parent 17846 24edc476ac18
child 17850 8fa257692c35
equal deleted inserted replaced
17846:24edc476ac18 17847:62aa54f44969
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 "{ Package: 'stx:libbasic' }"
    12 "{ Package: 'stx:libbasic' }"
    13 
    13 
    14 AbstractTime subclass:#Timestamp
    14 AbstractTime subclass:#Timestamp
    15         instanceVariableNames:'osTime'
    15 	instanceVariableNames:'osTime'
    16         classVariableNames:''
    16 	classVariableNames:''
    17         poolDictionaries:''
    17 	poolDictionaries:''
    18         category:'Magnitude-Time'
    18 	category:'Magnitude-Time'
    19 !
    19 !
    20 
    20 
    21 Object subclass:#TimestampBuilderAbstract
    21 Object subclass:#TimestampBuilderAbstract
    22         instanceVariableNames:'year month day hour minute second millisecond isUtcTime'
    22 	instanceVariableNames:'year month day hour minute second millisecond isUtcTime'
    23         classVariableNames:''
    23 	classVariableNames:''
    24         poolDictionaries:''
    24 	poolDictionaries:''
    25         privateIn:Timestamp
    25 	privateIn:Timestamp
    26 !
    26 !
    27 
    27 
    28 Timestamp::TimestampBuilderAbstract subclass:#TimestampISO8601Builder
    28 Timestamp::TimestampBuilderAbstract subclass:#TimestampISO8601Builder
    29         instanceVariableNames:'stream'
    29 	instanceVariableNames:'stream'
    30         classVariableNames:''
    30 	classVariableNames:''
    31         poolDictionaries:''
    31 	poolDictionaries:''
    32         privateIn:Timestamp
    32 	privateIn:Timestamp
    33 !
    33 !
    34 
    34 
    35 !Timestamp class methodsFor:'documentation'!
    35 !Timestamp class methodsFor:'documentation'!
    36 
    36 
    37 copyright
    37 copyright
   954         andTime:time) + utcOffset
   954         andTime:time) + utcOffset
   955 
   955 
   956     "Modified: / 05-10-2010 / 16:05:32 / cg"
   956     "Modified: / 05-10-2010 / 16:05:32 / cg"
   957 ! !
   957 ! !
   958 
   958 
   959 
       
   960 !Timestamp methodsFor:'accessing'!
   959 !Timestamp methodsFor:'accessing'!
   961 
   960 
   962 day
   961 day
   963     "return the day-in-month of the receiver (1..31).
   962     "return the day-in-month of the receiver (1..31).
   964      For compatibility, use instances of Date for this."
   963      For compatibility, use instances of Date for this."
  1471     ^ self utcSecondsSince1970 + 2177452800.  
  1470     ^ self utcSecondsSince1970 + 2177452800.  
  1472 
  1471 
  1473     "                                                 
  1472     "                                                 
  1474      Timestamp now utcSecondsSince1901 
  1473      Timestamp now utcSecondsSince1901 
  1475     "
  1474     "
       
  1475 ! !
       
  1476 
       
  1477 !Timestamp methodsFor:'double dispatching'!
       
  1478 
       
  1479 differenceFromTimestamp:aTimestamp
       
  1480     "/ the correct thing to do (and I will, in the future) is to
       
  1481     "/ return a TimeDuration:
       
  1482     "/
       
  1483     "/ ^ TimeDuration fromMilliseconds:(self getMilliseconds - (aTimestamp getMilliseconds))
       
  1484     "/ which is the same as: deltaFrom:aTimestamp
       
  1485     "/
       
  1486     "/ however, there might me old code around, which might not be prepared for
       
  1487     "/ getting a non-number (the seconds). Therefore, for the meantime,
       
  1488     "/ we return:
       
  1489 
       
  1490     ^ aTimestamp getSeconds - self getSeconds
       
  1491     "/ which is the same as: secondDeltaFrom:aTimestamp
       
  1492 
       
  1493     "/ be prepared for a change here.
       
  1494 
       
  1495     "Created: / 01-08-2011 / 16:38:10 / cg"
  1476 ! !
  1496 ! !
  1477 
  1497 
  1478 !Timestamp methodsFor:'initialization'!
  1498 !Timestamp methodsFor:'initialization'!
  1479 
  1499 
  1480 year:y month:m day:d hour:h minute:min second:s millisecond:millis 
  1500 year:y month:m day:d hour:h minute:min second:s millisecond:millis 
  1485                 hour:h
  1505                 hour:h
  1486                 minute:min
  1506                 minute:min
  1487                 seconds:s
  1507                 seconds:s
  1488                 millis:millis
  1508                 millis:millis
  1489 ! !
  1509 ! !
       
  1510 
  1490 
  1511 
  1491 !Timestamp methodsFor:'printing & storing'!
  1512 !Timestamp methodsFor:'printing & storing'!
  1492 
  1513 
  1493 addPrintBindingsTo:dict language:languageOrNil
  1514 addPrintBindingsTo:dict language:languageOrNil
  1494     "private print support: add bindings for printing to aDictionary
  1515     "private print support: add bindings for printing to aDictionary
  1848     "
  1869     "
  1849      Timestamp now utcSecondsSince1970
  1870      Timestamp now utcSecondsSince1970
  1850     "
  1871     "
  1851 ! !
  1872 ! !
  1852 
  1873 
  1853 
       
  1854 
       
  1855 !Timestamp methodsFor:'testing'!
  1874 !Timestamp methodsFor:'testing'!
  1856 
  1875 
  1857 isTimestamp
  1876 isTimestamp
  1858     ^ true
  1877     ^ true
  1859 !
  1878 !
  2638 ! !
  2657 ! !
  2639 
  2658 
  2640 !Timestamp class methodsFor:'documentation'!
  2659 !Timestamp class methodsFor:'documentation'!
  2641 
  2660 
  2642 version
  2661 version
  2643     ^ '$Id: Timestamp.st 10660 2011-07-18 15:22:09Z vranyj1 $'
  2662     ^ '$Id: Timestamp.st 10665 2011-08-10 14:59:08Z vranyj1 $'
  2644 !
  2663 !
  2645 
  2664 
  2646 version_CVS
  2665 version_CVS
  2647     ^ '§Header: /cvs/stx/stx/libbasic/Timestamp.st,v 1.136 2011/01/24 19:59:15 stefan Exp §'
  2666     ^ '§Header: /cvs/stx/stx/libbasic/Timestamp.st,v 1.138 2011/08/01 14:40:24 cg Exp §'
  2648 ! !
  2667 ! !
  2649 
  2668 
  2650 Timestamp initialize!
  2669 Timestamp initialize!
       
  2670