UtcTimestamp.st
changeset 17032 e2c097d59814
parent 17028 7f4490e83429
child 17051 060104d927c0
equal deleted inserted replaced
17031:d443175f7558 17032:e2c097d59814
    69     ^ 'UTC'
    69     ^ 'UTC'
    70 !
    70 !
    71 
    71 
    72 utcOffset
    72 utcOffset
    73     ^ 0
    73     ^ 0
       
    74 !
       
    75 
       
    76 utcOffsetWithoutDst
       
    77     ^ 0
    74 ! !
    78 ! !
    75 
    79 
    76 !UtcTimestamp methodsFor:'converting'!
    80 !UtcTimestamp methodsFor:'converting'!
    77 
       
    78 asDate
       
    79     "return a Date object from the receiver.
       
    80      The returned date will only represent the day - not the timeOfDay.
       
    81      Notice: if you convert a local timestamp, you will get the local date;
       
    82      otherwise if you convert an utcTimestamp, you'll get the utc date."
       
    83 
       
    84     (osTime between:MinOSTime and:MaxOSTime) ifFalse:[
       
    85         |dayDelta day0|
       
    86 
       
    87         dayDelta := osTime // (24 * 3600 * 1000).
       
    88         day0 := Epoch asDate.
       
    89         ^ day0 addDays:dayDelta.
       
    90     ].
       
    91     ^ self timeInfo asDate
       
    92 
       
    93     "
       
    94      Timestamp now
       
    95      Timestamp now asDate
       
    96      (Timestamp now addTime:3600) asDate
       
    97      (Timestamp now addTime:3600) asTime
       
    98      Timestamp fromSeconds:(Timestamp now asSeconds + 3600)
       
    99      (Timestamp fromSeconds:(Timestamp now asSeconds + 3600)) asDate
       
   100     "
       
   101 !
       
   102 
    81 
   103 asLocalTimestamp
    82 asLocalTimestamp
   104     "represent myself as a timestamp in the local timezone"
    83     "represent myself as a timestamp in the local timezone"
   105 
    84 
   106     ^ Timestamp fromOSTime:osTime
    85     ^ Timestamp fromOSTime:osTime
   107 !
       
   108 
       
   109 asTime
       
   110     "return a Time object from the receiver.
       
   111      The returned time will only represent the timeOfDay - not the day,
       
   112      and does not include the milliseconds."
       
   113 
       
   114     |secondDelta|
       
   115 
       
   116     (osTime between:MinOSTime and:MaxOSTime) ifFalse:[
       
   117         secondDelta := osTime // 1000.
       
   118         "/ we do not know about DST in the far future and in the long gone past.
       
   119         secondDelta := secondDelta rem:(24*3600) .
       
   120         ^ Epoch asTime addSeconds:secondDelta.
       
   121     ].
       
   122     ^ self timeInfo asTime
       
   123 !
    86 !
   124 
    87 
   125 asUtcTimestamp
    88 asUtcTimestamp
   126     "I am an UtcTimestamp"
    89     "I am an UtcTimestamp"
   127 
    90 
   169 ! !
   132 ! !
   170 
   133 
   171 !UtcTimestamp class methodsFor:'documentation'!
   134 !UtcTimestamp class methodsFor:'documentation'!
   172 
   135 
   173 version
   136 version
   174     ^ '$Header: /cvs/stx/stx/libbasic/UtcTimestamp.st,v 1.12 2014-11-11 12:14:23 stefan Exp $'
   137     ^ '$Header: /cvs/stx/stx/libbasic/UtcTimestamp.st,v 1.13 2014-11-11 13:08:59 stefan Exp $'
   175 !
   138 !
   176 
   139 
   177 version_CVS
   140 version_CVS
   178     ^ '$Header: /cvs/stx/stx/libbasic/UtcTimestamp.st,v 1.12 2014-11-11 12:14:23 stefan Exp $'
   141     ^ '$Header: /cvs/stx/stx/libbasic/UtcTimestamp.st,v 1.13 2014-11-11 13:08:59 stefan Exp $'
   179 ! !
   142 ! !
   180 
   143