AbstractOperatingSystem.st
changeset 11843 b5bd41fe1e8f
parent 11835 bf65bdad3827
child 11846 77deb8041ea1
--- a/AbstractOperatingSystem.st	Wed Aug 12 15:13:17 2009 +0200
+++ b/AbstractOperatingSystem.st	Wed Aug 12 15:17:29 2009 +0200
@@ -35,6 +35,16 @@
 	privateIn:AbstractOperatingSystem
 !
 
+Object subclass:#TimeZoneInfo
+	instanceVariableNames:'bias name standardYear standardMonth standardDay standardWeekDay
+		standardHour standardMinute standardBias daylightName
+		daylightYear daylightMonth daylightDay daylightWeekDay
+		daylightHour daylightMinute daylightBias'
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:AbstractOperatingSystem
+!
+
 !AbstractOperatingSystem primitiveDefinitions!
 %{
 
@@ -6583,6 +6593,10 @@
      If utcOffset is positive, the local timezone is west of Greenwich."
 
     ^ utcOffset
+
+    "
+     OperatingSystem utcOffset
+    "
 !
 
 year
@@ -6620,10 +6634,278 @@
     dayInWeek := dayInWeekArg.
 ! !
 
+!AbstractOperatingSystem::TimeZoneInfo class methodsFor:'documentation'!
+
+documentation
+"
+Bias
+    The current bias for local time translation on this computer, in minutes. 
+    The bias is the difference, in minutes, between Coordinated Universal Time (UTC) 
+    and local time. 
+    All translations between UTC and local time are based on the following formula:
+
+        UTC = local time + bias
+
+StandardName
+    A description for standard time. For example, 'EST' could indicate Eastern Standard Time. 
+    The string will be returned unchanged by the GetTimeZoneInformation function. 
+    This string can be empty.
+    This is for information only - do not depend on the value of the string.
+
+StandardDate
+    A Timestamp that contains a date and local time when the transition from daylight saving 
+    time to standard time occurs on this operating system. 
+    If the time zone does not support daylight saving time or if the caller needs to disable 
+    daylight saving time, the standardDate is nil.
+    If this date is specified, the DaylightDate member of this structure must also be specified. 
+    Otherwise, the system assumes the time zone data is invalid and no changes will be applied.
+
+    To select the correct day in the month, set the wYear member to zero, the wHour and wMinute members 
+    to the transition time, the wDayOfWeek member to the appropriate weekday, and the wDay member to indicate 
+    the occurrence of the day of the week within the month (1 to 5, where 5 indicates the final occurrence 
+    during the month if that day of the week does not occur 5 times).
+
+    Using this notation, specify 02:00 on the first Sunday in April as follows: 
+        wHour = 2, wMonth = 4, wDayOfWeek = 0, wDay = 1. 
+    Specify 02:00 on the last Thursday in October as follows: 
+        wHour = 2, wMonth = 10, wDayOfWeek = 4, wDay = 5.
+
+    If the wYear member is not zero, the transition date is absolute; it will only occur one time. 
+    Otherwise, it is a relative date that occurs yearly.
+
+StandardBias
+    The bias value to be used during local time translations that occur during standard time. 
+    This member is ignored if a value for the StandardDate member is not supplied.
+
+    This value is added to the value of the Bias member to form the bias used during standard time. 
+    In most time zones, the value of this member is zero.
+
+DaylightName
+    A description for daylight saving time. For example, 'PDT' could indicate Pacific Daylight Time. 
+    The string will be returned unchanged by the GetTimeZoneInformation function. This string can be empty.
+    This is for information only - do not depend on the value of the string.
+
+DaylightDate
+    A Timestamp structure that contains a date and local time when the transition from standard time 
+    to daylight saving time occurs on this operating system. 
+    If the time zone does not support daylight saving time or if the caller needs to disable daylight 
+    saving time, this entry is nil.
+    If this date is specified, the StandardDate member in this structure must also be specified. 
+    Otherwise, the system assumes the time zone data is invalid and no changes will be applied.
+
+    To select the correct day in the month, set the wYear member to zero, the wHour and wMinute members to 
+    the transition time, the wDayOfWeek member to the appropriate weekday, and the wDay member to indicate 
+    the occurrence of the day of the week within the month (1 to 5, where 5 indicates the final occurrence 
+    during the month if that day of the week does not occur 5 times).
+
+    If the wYear member is not zero, the transition date is absolute; it will only occur one time. 
+    Otherwise, it is a relative date that occurs yearly.
+
+DaylightBias
+    The bias value to be used during local time translations that occur during daylight saving time. 
+    This member is ignored if a value for the DaylightDate member is not supplied.
+
+    This value is added to the value of the Bias member to form the bias used during daylight saving time. 
+    In most time zones, the value of this member is -60
+"
+! !
+
+!AbstractOperatingSystem::TimeZoneInfo methodsFor:'accessing'!
+
+bias
+    ^ bias
+!
+
+bias:something
+    bias := something.
+!
+
+bias:biasArg name:nameArg standardBias:standardBiasArg daylightName:daylightNameArg daylightBias:daylightBiasArg 
+    bias := biasArg.
+    name := nameArg.
+    standardBias := standardBiasArg.
+    daylightName := daylightNameArg.
+    daylightBias := daylightBiasArg.
+!
+
+bias:biasArg name:nameArg standardDate:standardDateArg standardBias:standardBiasArg daylightName:daylightNameArg daylightDate:daylightDateArg daylightBias:daylightBiasArg 
+    bias := biasArg.
+    name := nameArg.
+    standardDate := standardDateArg.
+    standardBias := standardBiasArg.
+    daylightName := daylightNameArg.
+    daylightDate := daylightDateArg.
+    daylightBias := daylightBiasArg.
+!
+
+daylightBias
+    ^ daylightBias
+!
+
+daylightBias:something
+    daylightBias := something.
+!
+
+daylightDay
+    ^ daylightDay
+!
+
+daylightDay:something
+    daylightDay := something.
+!
+
+daylightHour
+    ^ daylightHour
+!
+
+daylightHour:something
+    daylightHour := something.
+!
+
+daylightMinute
+    ^ daylightMinute
+!
+
+daylightMinute:something
+    daylightMinute := something.
+!
+
+daylightMonth
+    ^ daylightMonth
+!
+
+daylightMonth:something
+    daylightMonth := something.
+!
+
+daylightName
+    ^ daylightName
+!
+
+daylightName:something
+    daylightName := something.
+!
+
+daylightWeekDay
+    ^ daylightWeekDay
+!
+
+daylightWeekDay:something
+    daylightWeekDay := something.
+!
+
+daylightYear
+    ^ daylightYear
+!
+
+daylightYear:something
+    daylightYear := something.
+!
+
+daylightYear:daylightYearArg daylightMonth:daylightMonthArg daylightDay:daylightDayArg daylightWeekDay:daylightWeekDayArg daylightHour:daylightHourArg daylightMinute:daylightMinuteArg 
+    daylightYear := daylightYearArg.
+    daylightMonth := daylightMonthArg.
+    daylightDay := daylightDayArg.
+    daylightWeekDay := daylightWeekDayArg.
+    daylightHour := daylightHourArg.
+    daylightMinute := daylightMinuteArg.
+!
+
+name
+    ^ name
+!
+
+name:something
+    name := something.
+!
+
+standardBias
+    ^ standardBias
+!
+
+standardBias:something
+    standardBias := something.
+!
+
+standardDay
+    ^ standardDay
+!
+
+standardDay:something
+    standardDay := something.
+!
+
+standardHour
+    ^ standardHour
+!
+
+standardHour:something
+    standardHour := something.
+!
+
+standardMinute
+    ^ standardMinute
+!
+
+standardMinute:something
+    standardMinute := something.
+!
+
+standardMonth
+    ^ standardMonth
+!
+
+standardMonth:something
+    standardMonth := something.
+!
+
+standardWeekDay
+    ^ standardWeekDay
+!
+
+standardWeekDay:something
+    standardWeekDay := something.
+!
+
+standardYear
+    ^ standardYear
+!
+
+standardYear:something
+    standardYear := something.
+!
+
+standardYear:standardYearArg standardMonth:standardMonthArg standardDay:standardDayArg standardWeekDay:standardWeekDayArg standardHour:standardHourArg standardMinute:standardMinuteArg 
+    standardYear := standardYearArg.
+    standardMonth := standardMonthArg.
+    standardDay := standardDayArg.
+    standardWeekDay := standardWeekDayArg.
+    standardHour := standardHourArg.
+    standardMinute := standardMinuteArg.
+! !
+
+!AbstractOperatingSystem::TimeZoneInfo methodsFor:'queries'!
+
+utcOffset
+    "return the difference between UTC (Greenwich Mean Time) and the local time in seconds.
+     If daylight saving time applies to ourself, take that into account.
+     Add utcOffset to convert from local time to UTC time.
+     Subtract utcOffset to convert from UTC time to local time.
+
+     If utcOffset is negative, the local timezone is east of Greenwich.
+     If utcOffset is positive, the local timezone is west of Greenwich."
+
+    ^ (bias + daylightBias) * 60
+
+    "
+     OperatingSystem utcOffset
+    "
+! !
+
 !AbstractOperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.187 2009-08-05 09:12:24 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.188 2009-08-12 13:17:29 cg Exp $'
 ! !
 
 AbstractOperatingSystem initialize!