Source for file TimeZone.class.php

Documentation is available at TimeZone.class.php

  1. <?php
  2. /**
  3. * @since 5/3/05
  4. * @package harmoni.primitives.chronology
  5. *
  6. * @copyright Copyright &copy; 2005, Middlebury College
  7. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  8. *
  9. * @version $Id: TimeZone.class.php,v 1.4 2007/09/04 20:25:25 adamfranco Exp $
  10. *
  11. * @link http://harmoni.sourceforge.net/
  12. * @author Adam Franco <adam AT adamfranco DOT com> <afranco AT middlebury DOT edu>
  13. */
  14.  
  15. require_once(dirname(__FILE__)."/../Objects/SObject.class.php");
  16.  
  17. /**
  18. * TimeZone is a simple class to colect the information identifying a UTC time zone.
  19. *
  20. * - offset - Duration - the time zone's offset from UTC
  21. * - abbreviation - String - the abbreviated name for the time zone.
  22. * - name - String - the name of the time zone.
  23. *
  24. * TimeZone class >> timeZones() returns an array of the known time zones
  25. * TimeZone class >> defaultTimeZone() returns the default time zone (Grenwich Mean Time)
  26. * DateAndTime class >> localTimeZone() returns the local time zone.
  27. *
  28. * To create new TimeZone instances, <b>use one of the static instance-creation
  29. * methods</b>, NOT 'new TimeZone':
  30. * - {@link defaultTimeZone TimeZone::defaultTimeZone()}
  31. * - {@link defaultTimeZone TimeZone::defaultTimeZone()}
  32. * - {@link offsetNameAbbreviation TimeZone::offsetNameAbbreviation($aDuration,}
  33. * $aStringName, $aStringAbbreviation)}
  34. *
  35. * @since 5/3/05
  36. * @package harmoni.primitives.chronology
  37. *
  38. * @copyright Copyright &copy; 2005, Middlebury College
  39. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  40. *
  41. * @version $Id: TimeZone.class.php,v 1.4 2007/09/04 20:25:25 adamfranco Exp $
  42. *
  43. * @link http://harmoni.sourceforge.net/
  44. * @author Adam Franco <adam AT adamfranco DOT com> <afranco AT middlebury DOT edu>
  45. */
  46. class TimeZone
  47. extends SObject
  48. {
  49.  
  50. /*******************************************************
  51. * Class Methods - Instance Creation
  52. *********************************************************/
  53. /**
  54. * Answer the default time zone - GMT
  55. *
  56. * @return object TimeZone
  57. * @access public
  58. * @since 5/3/05
  59. * @static
  60. */
  61. function defaultTimeZone () {
  62. $obj = TimeZone::offsetNameAbbreviation(
  63. Duration::withHours(0),
  64. 'Greenwich Mean Time',
  65. 'GMT');
  66. return $obj;
  67. }
  68. /**
  69. * Create a new Timezone.
  70. *
  71. * @param object Duration $aDuration
  72. * @param string $aStringName
  73. * @param string $aStringAbbriviation
  74. * @return object TimeZone
  75. * @access public
  76. * @since 5/3/05
  77. */
  78. function offsetNameAbbreviation ( $aDuration, $aStringName = NULL,
  79. $aStringAbbreviation = NULL)
  80. {
  81. $obj = new TimeZone ($aDuration, $aStringName, $aStringAbbreviation );
  82. return $obj;
  83. }
  84. /*******************************************************
  85. * Class Methods - Accessing
  86. *********************************************************/
  87.  
  88. /**
  89. * Return an Array of TimeZones
  90. *
  91. * @return array
  92. * @access public
  93. * @since 5/3/05
  94. * @static
  95. */
  96. function timeZones () {
  97. $array = array (
  98. TimeZone::offsetNameAbbreviation(
  99. Duration::withHours(0),
  100. 'Universal Time',
  101. 'UTC'),
  102. TimeZone::offsetNameAbbreviation(
  103. Duration::withHours(0),
  104. 'Greenwich Mean Time',
  105. 'GMT'),
  106. TimeZone::offsetNameAbbreviation(
  107. Duration::withHours(0),
  108. 'British Summer Time',
  109. 'BST'),
  110. TimeZone::offsetNameAbbreviation(
  111. Duration::withHours(-5),
  112. 'Eastern Standard Time',
  113. 'EST'),
  114. TimeZone::offsetNameAbbreviation(
  115. Duration::withHours(-4),
  116. 'Eastern Daylight Time',
  117. 'EDT'),
  118. TimeZone::offsetNameAbbreviation(
  119. Duration::withHours(-6),
  120. 'Central Standard Time',
  121. 'CST'),
  122. TimeZone::offsetNameAbbreviation(
  123. Duration::withHours(-5),
  124. 'Central Daylight Time',
  125. 'CDT'),
  126. TimeZone::offsetNameAbbreviation(
  127. Duration::withHours(-7),
  128. 'Mountain Standard Time',
  129. 'MST'),
  130. TimeZone::offsetNameAbbreviation(
  131. Duration::withHours(-6),
  132. 'Mountain Daylight Time',
  133. 'MDT'),
  134. TimeZone::offsetNameAbbreviation(
  135. Duration::withHours(-8),
  136. 'Pacific Standard Time',
  137. 'PST'),
  138. TimeZone::offsetNameAbbreviation(
  139. Duration::withHours(-7),
  140. 'Pacific Daylight Time',
  141. 'PDT'),
  142. );
  143. return $array;
  144. }
  145. /*******************************************************
  146. * Instance Methods - private
  147. *********************************************************/
  148.  
  149. /**
  150. * Create a new Timezone.
  151. *
  152. * @param object Duration $aDuration
  153. * @param string $aStringName
  154. * @param string $aStringAbbriviation
  155. * @return object TimeZone
  156. * @access private
  157. * @since 5/3/05
  158. */
  159. function TimeZone ( $aDuration, $aStringName, $aStringAbbreviation ) {
  160. $this->offset =$aDuration;
  161. $this->name = $aStringName;
  162. $this->abbreviation = $aStringAbbreviation;
  163. }
  164. /*******************************************************
  165. * Instance Methods - Accessing
  166. *********************************************************/
  167.  
  168. /**
  169. * Return the offset of this TimeZone
  170. *
  171. * @return object Duration
  172. * @access public
  173. * @since 5/3/05
  174. */
  175. function offset () {
  176. return $this->offset;
  177. }
  178. /**
  179. * Answer the abreviation
  180. *
  181. * @return string
  182. * @access public
  183. * @since 5/10/05
  184. */
  185. function abbreviation () {
  186. return $this->abbreviation;
  187. }
  188. /**
  189. * Answer the name
  190. *
  191. * @return string
  192. * @access public
  193. * @since 5/10/05
  194. */
  195. function name () {
  196. return $this->name;
  197. }
  198. }
  199.  
  200. ?>

Documentation generated on Wed, 19 Sep 2007 10:27:30 -0400 by phpDocumentor 1.3.0RC3