[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/phpgwapi/inc/ -> class.egw_datetime.inc.php (source)

   1  <?php
   2      /**************************************************************************\
   3      * eGroupWare API - Commononly used functions                               *
   4      * This file written by Dan Kuykendall <seek3r@phpgroupware.org>            *
   5      * and Joseph Engo <jengo@phpgroupware.org>                                 *
   6      * and Mark Peters <skeeter@phpgroupware.org>                               *
   7      * Commononly used functions by phpGroupWare developers                     *
   8      * Copyright (C) 2000, 2001 Dan Kuykendall                                  *
   9      * ------------------------------------------------------------------------ *
  10      * This library is part of the eGroupWare API                               *
  11      * http://www.egroupware.org                                                *
  12      * ------------------------------------------------------------------------ *
  13      * This library is free software; you can redistribute it and/or modify it  *
  14      * under the terms of the GNU Lesser General Public License as published by *
  15      * the Free Software Foundation; either version 2.1 of the License,         *
  16      * or any later version.                                                    *
  17      * This library is distributed in the hope that it will be useful, but      *
  18      * WITHOUT ANY WARRANTY; without even the implied warranty of               *
  19      * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     *
  20      * See the GNU Lesser General Public License for more details.              *
  21      * You should have received a copy of the GNU Lesser General Public License *
  22      * along with this library; if not, write to the Free Software Foundation,  *
  23      * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            *
  24      \**************************************************************************/
  25  
  26      /* $Id: class.egw_datetime.inc.php 22825 2006-11-10 11:38:34Z ralfbecker $ */
  27  
  28      $d1 = strtolower(@substr(EGW_API_INC,0,3));
  29      $d2 = strtolower(@substr(EGW_SERVER_ROOT,0,3));
  30      $d3 = strtolower(@substr(EGW_APP_INC,0,3));
  31      if($d1 == 'htt' || $d1 == 'ftp' || $d2 == 'htt' || $d2 == 'ftp' || $d3 == 'htt' || $d3 == 'ftp')
  32      {
  33          echo 'Failed attempt to break in via an old Security Hole!<br>'."\n";
  34          exit;
  35      }
  36      unset($d1);
  37      unset($d2);
  38      unset($d3);
  39  
  40      /**
  41      * eGroupWare datetime class that contains common date/time functions
  42      * 
  43      * renamed to egw_datetime to support php5.2
  44      */
  45      class egw_datetime
  46      {
  47          var $zone_offset_list = array(
  48              'ACT' => '+9:30',
  49              'AET' => '+10:00',
  50              'Africa/Abidjan' => '+0.0',
  51              'Africa/Accra' => '+0.0',
  52              'Africa/Addis_Ababa' => '+3:00',
  53              'Africa/Algiers' => '-11:00',
  54              'Africa/Asmera' => '+3:00',
  55              'Africa/Bamako' => '+0.0',
  56              'Africa/Bangui' => '-11:00',
  57              'Africa/Banjul' => '+0.0',
  58              'Africa/Bissau' => '+0.0',
  59              'Africa/Blantyre' => '+2:00',
  60              'Africa/Brazzaville' => '-11:00',
  61              'Africa/Bujumbura' => '+2:00',
  62              'Africa/Cairo' => '+2:00',
  63              'Africa/Casablanca' => '+0.0',
  64              'Africa/Ceuta' => '-11:00',
  65              'Africa/Conakry' => '+0.0',
  66              'Africa/Dakar' => '+0.0',
  67              'Africa/Dar_es_Salaam' => '+3:00',
  68              'Africa/Djibouti' => '+3:00',
  69              'Africa/Douala' => '-11:00',
  70              'Africa/El_Aaiun' => '+0.0',
  71              'Africa/Freetown' => '+0.0',
  72              'Africa/Gaborone' => '+2:00',
  73              'Africa/Harare' => '+2:00',
  74              'Africa/Johannesburg' => '+2:00',
  75              'Africa/Kampala' => '+3:00',
  76              'Africa/Khartoum' => '+3:00',
  77              'Africa/Kigali' => '+2:00',
  78              'Africa/Kinshasa' => '-11:00',
  79              'Africa/Lagos' => '-11:00',
  80              'Africa/Libreville' => '-11:00',
  81              'Africa/Lome' => '+0.0',
  82              'Africa/Luanda' => '-11:00',
  83              'Africa/Lubumbashi' => '+2:00',
  84              'Africa/Lusaka' => '+2:00',
  85              'Africa/Malabo' => '-11:00',
  86              'Africa/Maputo' => '+2:00',
  87              'Africa/Maseru' => '+2:00',
  88              'Africa/Mbabane' => '+2:00',
  89              'Africa/Mogadishu' => '+3:00',
  90              'Africa/Monrovia' => '+0.0',
  91              'Africa/Nairobi' => '+3:00',
  92              'Africa/Ndjamena' => '-11:00',
  93              'Africa/Niamey' => '-11:00',
  94              'Africa/Nouakchott' => '+0.0',
  95              'Africa/Ouagadougou' => '+0.0',
  96              'Africa/Porto-Novo' => '-11:00',
  97              'Africa/Sao_Tome' => '+0.0',
  98              'Africa/Timbuktu' => '+0.0',
  99              'Africa/Tripoli' => '+2:00',
 100              'Africa/Tunis' => '-11:00',
 101              'Africa/Windhoek' => '-11:00',
 102              'AGT' => '-3:00',
 103              'America/Adak' => '-10:00',
 104              'America/Anchorage' => '-8:00',
 105              'America/Anguilla' => '-3:30',
 106              'America/Antigua' => '-3:30',
 107              'America/Araguaina' => '-3:00',
 108              'America/Aruba' => '-3:30',
 109              'America/Asuncion' => '-3:30',
 110              'America/Atka' => '-10:00',
 111              'America/Barbados' => '-3:30',
 112              'America/Belem' => '-3:00',
 113              'America/Belize' => '-6:00',
 114              'America/Boa_Vista' => '-3:30',
 115              'America/Bogota' => '-5:00',
 116              'America/Boise' => '-7:00',
 117              'America/Buenos_Aires' => '-3:00',
 118              'America/Cambridge_Bay' => '-7:00',
 119              'America/Cancun' => '-6:00',
 120              'America/Caracas' => '-3:30',
 121              'America/Catamarca' => '-3:00',
 122              'America/Cayenne' => '-3:00',
 123              'America/Cayman' => '-5:00',
 124              'America/Chicago' => '-6:00',
 125              'America/Chihuahua' => '-7:00',
 126              'America/Cordoba' => '-3:00',
 127              'America/Costa_Rica' => '-6:00',
 128              'America/Cuiaba' => '-3:30',
 129              'America/Curacao' => '-3:30',
 130              'America/Danmarkshavn' => '+0.0',
 131              'America/Dawson' => '-8:00',
 132              'America/Dawson_Creek' => '-7:00',
 133              'America/Denver' => '-7:00',
 134              'America/Detroit' => '-5:00',
 135              'America/Dominica' => '-3:30',
 136              'America/Edmonton' => '-7:00',
 137              'America/Eirunepe' => '-5:00',
 138              'America/El_Salvador' => '-6:00',
 139              'America/Ensenada' => '-8:00',
 140              'America/Fortaleza' => '-3:00',
 141              'America/Fort_Wayne' => '-5:00',
 142              'America/Glace_Bay' => '-3:30',
 143              'America/Godthab' => '-3:00',
 144              'America/Goose_Bay' => '-3:30',
 145              'America/Grand_Turk' => '-5:00',
 146              'America/Grenada' => '-3:30',
 147              'America/Guadeloupe' => '-3:30',
 148              'America/Guatemala' => '-6:00',
 149              'America/Guayaquil' => '-5:00',
 150              'America/Guyana' => '-3:30',
 151              'America/Halifax' => '-3:30',
 152              'America/Havana' => '-5:00',
 153              'America/Hermosillo' => '-7:00',
 154              'America/Indiana/Indianapolis' => '-5:00',
 155              'America/Indiana/Knox' => '-5:00',
 156              'America/Indiana/Marengo' => '-5:00',
 157              'America/Indianapolis' => '-5:00',
 158              'America/Indiana/Vevay' => '-5:00',
 159              'America/Inuvik' => '-7:00',
 160              'America/Iqaluit' => '-5:00',
 161              'America/Jamaica' => '-5:00',
 162              'America/Jujuy' => '-3:00',
 163              'America/Juneau' => '-8:00',
 164              'America/Kentucky/Louisville' => '-5:00',
 165              'America/Kentucky/Monticello' => '-5:00',
 166              'America/Knox_IN' => '-5:00',
 167              'America/La_Paz' => '-3:30',
 168              'America/Lima' => '-5:00',
 169              'America/Los_Angeles' => '-8:00',
 170              'America/Louisville' => '-5:00',
 171              'America/Maceio' => '-3:00',
 172              'America/Managua' => '-6:00',
 173              'America/Manaus' => '-3:30',
 174              'America/Martinique' => '-3:30',
 175              'America/Mazatlan' => '-7:00',
 176              'America/Mendoza' => '-3:00',
 177              'America/Menominee' => '-6:00',
 178              'America/Merida' => '-6:00',
 179              'America/Mexico_City' => '-6:00',
 180              'America/Miquelon' => '-3:00',
 181              'America/Monterrey' => '-6:00',
 182              'America/Montevideo' => '-3:00',
 183              'America/Montreal' => '-5:00',
 184              'America/Montserrat' => '-3:30',
 185              'America/Nassau' => '-5:00',
 186              'America/New_York' => '-5:00',
 187              'America/Nipigon' => '-5:00',
 188              'America/Nome' => '-8:00',
 189              'America/Noronha' => '-2:00',
 190              'America/North_Dakota/Center' => '-6:00',
 191              'America/Panama' => '-5:00',
 192              'America/Pangnirtung' => '-5:00',
 193              'America/Paramaribo' => '-3:00',
 194              'America/Phoenix' => '-7:00',
 195              'America/Port-au-Prince' => '-5:00',
 196              'America/Porto_Acre' => '-5:00',
 197              'America/Port_of_Spain' => '-3:30',
 198              'America/Porto_Velho' => '-3:30',
 199              'America/Puerto_Rico' => '-3:30',
 200              'America/Rainy_River' => '-6:00',
 201              'America/Rankin_Inlet' => '-6:00',
 202              'America/Recife' => '-3:00',
 203              'America/Regina' => '-6:00',
 204              'America/Rio_Branco' => '-5:00',
 205              'America/Rosario' => '-3:00',
 206              'America/Santiago' => '-3:30',
 207              'America/Santo_Domingo' => '-3:30',
 208              'America/Sao_Paulo' => '-3:00',
 209              'America/Scoresbysund' => '-1:00',
 210              'America/Shiprock' => '-7:00',
 211              'America/St_Johns' => '-3:30',
 212              'America/St_Kitts' => '-3:30',
 213              'America/St_Lucia' => '-3:30',
 214              'America/St_Thomas' => '-3:30',
 215              'America/St_Vincent' => '-3:30',
 216              'America/Swift_Current' => '-6:00',
 217              'America/Tegucigalpa' => '-6:00',
 218              'America/Thule' => '-3:30',
 219              'America/Thunder_Bay' => '-5:00',
 220              'America/Tijuana' => '-8:00',
 221              'America/Tortola' => '-3:30',
 222              'America/Vancouver' => '-8:00',
 223              'America/Virgin' => '-3:30',
 224              'America/Whitehorse' => '-8:00',
 225              'America/Winnipeg' => '-6:00',
 226              'America/Yakutat' => '-8:00',
 227              'America/Yellowknife' => '-7:00',
 228              'Antarctica/Casey' => '+8:00',
 229              'Antarctica/Davis' => '+7:00',
 230              'Antarctica/DumontDUrville' => '+10:00',
 231              'Antarctica/Mawson' => '+6:00',
 232              'Antarctica/Palmer' => '-3:30',
 233              'Antarctica/Syowa' => '+3:00',
 234              'Antarctica/Vostok' => '+6:00',
 235              'Arctic/Longyearbyen' => '-11:00',
 236              'ART' => '+2:00',
 237              'Asia/Aden' => '+3:00',
 238              'Asia/Almaty' => '+6:00',
 239              'Asia/Amman' => '+2:00',
 240              'Asia/Aqtau' => '+4:00',
 241              'Asia/Aqtobe' => '+5:00',
 242              'Asia/Ashgabat' => '+5:00',
 243              'Asia/Ashkhabad' => '+5:00',
 244              'Asia/Baghdad' => '+3:00',
 245              'Asia/Bahrain' => '+3:00',
 246              'Asia/Baku' => '+4:00',
 247              'Asia/Bangkok' => '+7:00',
 248              'Asia/Beirut' => '+2:00',
 249              'Asia/Bishkek' => '+5:00',
 250              'Asia/Brunei' => '+8:00',
 251              'Asia/Calcutta' => '+5:30:',
 252              'Asia/Choibalsan' => '+9:00',
 253              'Asia/Chongqing' => '+8:00',
 254              'Asia/Chungking' => '+8:00',
 255              'Asia/Colombo' => '+6:00',
 256              'Asia/Dacca' => '+6:00',
 257              'Asia/Damascus' => '+2:00',
 258              'Asia/Dhaka' => '+6:00',
 259              'Asia/Dili' => '+9:00',
 260              'Asia/Dubai' => '+4:00',
 261              'Asia/Dushanbe' => '+5:00',
 262              'Asia/Gaza' => '+2:00',
 263              'Asia/Harbin' => '+8:00',
 264              'Asia/Hong_Kong' => '+8:00',
 265              'Asia/Hovd' => '+7:00',
 266              'Asia/Irkutsk' => '+8:00',
 267              'Asia/Istanbul' => '+2:00',
 268              'Asia/Jakarta' => '+7:00',
 269              'Asia/Jayapura' => '+9:00',
 270              'Asia/Jerusalem' => '+2:00',
 271              'Asia/Kabul' => '+4:30',
 272              'Asia/Karachi' => '+5:00',
 273              'Asia/Kashgar' => '+8:00',
 274              'Asia/Katmandu' => '+5:45',
 275              'Asia/Krasnoyarsk' => '+7:00',
 276              'Asia/Kuala_Lumpur' => '+8:00',
 277              'Asia/Kuching' => '+8:00',
 278              'Asia/Kuwait' => '+3:00',
 279              'Asia/Macao' => '+8:00',
 280              'Asia/Macau' => '+8:00',
 281              'Asia/Magadan' => '+11:00',
 282              'Asia/Makassar' => '+8:00',
 283              'Asia/Manila' => '+8:00',
 284              'Asia/Muscat' => '+4:00',
 285              'Asia/Nicosia' => '+2:00',
 286              'Asia/Novosibirsk' => '+6:00',
 287              'Asia/Omsk' => '+6:00',
 288              'Asia/Oral' => '+4:00',
 289              'Asia/Phnom_Penh' => '+7:00',
 290              'Asia/Pontianak' => '+7:00',
 291              'Asia/Pyongyang' => '+9:00',
 292              'Asia/Qatar' => '+3:00',
 293              'Asia/Qyzylorda' => '+6:00',
 294              'Asia/Rangoon' => '+6:30',
 295              'Asia/Riyadh' => '+3:00',
 296              'Asia/Saigon' => '+7:00',
 297              'Asia/Sakhalin' => '+10:00',
 298              'Asia/Samarkand' => '+5:00',
 299              'Asia/Seoul' => '+9:00',
 300              'Asia/Shanghai' => '+8:00',
 301              'Asia/Singapore' => '+8:00',
 302              'Asia/Taipei' => '+8:00',
 303              'Asia/Tashkent' => '+5:00',
 304              'Asia/Tbilisi' => '+4:00',
 305              'Asia/Tehran' => '+3:30',
 306              'Asia/Tel_Aviv' => '+2:00',
 307              'Asia/Thimbu' => '+6:00',
 308              'Asia/Thimphu' => '+6:00',
 309              'Asia/Tokyo' => '+9:00',
 310              'Asia/Ujung_Pandang' => '+8:00',
 311              'Asia/Ulaanbaatar' => '+8:00',
 312              'Asia/Ulan_Bator' => '+8:00',
 313              'Asia/Urumqi' => '+8:00',
 314              'Asia/Vientiane' => '+7:00',
 315              'Asia/Vladivostok' => '+10:00',
 316              'Asia/Yakutsk' => '+9:00',
 317              'Asia/Yekaterinburg' => '+5:00',
 318              'Asia/Yerevan' => '+4:00',
 319              'AST' => '-8:00',
 320              'Atlantic/Azores' => '-1:00',
 321              'Atlantic/Bermuda' => '-3:30',
 322              'Atlantic/Canary' => '+0.0',
 323              'Atlantic/Cape_Verde' => '-1:00',
 324              'Atlantic/Faeroe' => '+0.0',
 325              'Atlantic/Jan_Mayen' => '-11:00',
 326              'Atlantic/Madeira' => '+0.0',
 327              'Atlantic/Reykjavik' => '+0.0',
 328              'Atlantic/South_Georgia' => '-2:00',
 329              'Atlantic/Stanley' => '-3:30',
 330              'Atlantic/St_Helena' => '+0.0',
 331              'Australia/ACT' => '+10:00',
 332              'Australia/Adelaide' => '+9:30',
 333              'Australia/Brisbane' => '+10:00',
 334              'Australia/Broken_Hill' => '+9:30',
 335              'Australia/Canberra' => '+10:00',
 336              'Australia/Darwin' => '+9:30',
 337              'Australia/Hobart' => '+10:00',
 338              'Australia/LHI' => '+10:30',
 339              'Australia/Lindeman' => '+10:00',
 340              'Australia/Lord_Howe' => '+10:30',
 341              'Australia/Melbourne' => '+10:00',
 342              'Australia/North' => '+9:30',
 343              'Australia/NSW' => '+10:00',
 344              'Australia/Perth' => '+8:00',
 345              'Australia/Queensland' => '+10:00',
 346              'Australia/South' => '+9:30',
 347              'Australia/Sydney' => '+10:00',
 348              'Australia/Tasmania' => '+10:00',
 349              'Australia/Victoria' => '+10:00',
 350              'Australia/West' => '+8:00',
 351              'Australia/Yancowinna' => '+9:30',
 352              'BET' => '-3:00',
 353              'Brazil/Acre' => '-5:00',
 354              'Brazil/DeNoronha' => '-2:00',
 355              'Brazil/East' => '-3:00',
 356              'Brazil/West' => '-3:30',
 357              'BST' => '+6:00',
 358              'Canada/Atlantic' => '-3:30',
 359              'Canada/Central' => '-6:00',
 360              'Canada/Eastern' => '-5:00',
 361              'Canada/East-Saskatchewan' => '-6:00',
 362              'Canada/Mountain' => '-7:00',
 363              'Canada/Newfoundland' => '-3:30',
 364              'Canada/Pacific' => '-8:00',
 365              'Canada/Saskatchewan' => '-6:00',
 366              'Canada/Yukon' => '-8:00',
 367              'CAT' => '+2:00',
 368              'CET' => '-11:00',
 369              'Chile/Continental' => '-3:30',
 370              'Chile/EasterIsland' => '-6:00',
 371              'CNT' => '-3:30',
 372              'CST' => '-6:00',
 373              'CST6CDT' => '-6:00',
 374              'CTT' => '+8:00',
 375              'Cuba' => '-5:00',
 376              'EAT' => '+3:00',
 377              'ECT' => '-11:00',
 378              'EET' => '+2:00',
 379              'Egypt' => '+2:00',
 380              'Eire' => '+0.0',
 381              'EST' => '-5:00',
 382              'EST5EDT' => '-5:00',
 383              'Etc/GMT' => '+0.0',
 384              'Etc/-0' => '+0.0',
 385              'Etc/+0' => '+0.0',
 386              'Etc/GMT0' => '+0.0',
 387              'Etc/Greenwich' => '+0.0',
 388              'Etc/UCT' => '+0.0',
 389              'Etc/Universal' => '+0.0',
 390              'Etc/UTC' => '+0.0',
 391              'Etc/Zulu' => '+0.0',
 392              'Europe/Amsterdam' => '-11:00',
 393              'Europe/Andorra' => '-11:00',
 394              'Europe/Athens' => '+2:00',
 395              'Europe/Belfast' => '+0.0',
 396              'Europe/Belgrade' => '-11:00',
 397              'Europe/Berlin' => '-11:00',
 398              'Europe/Bratislava' => '-11:00',
 399              'Europe/Brussels' => '-11:00',
 400              'Europe/Bucharest' => '+2:00',
 401              'Europe/Budapest' => '-11:00',
 402              'Europe/Chisinau' => '+2:00',
 403              'Europe/Copenhagen' => '-11:00',
 404              'Europe/Dublin' => '+0.0',
 405              'Europe/Gibraltar' => '-11:00',
 406              'Europe/Helsinki' => '+2:00',
 407              'Europe/Istanbul' => '+2:00',
 408              'Europe/Kaliningrad' => '+2:00',
 409              'Europe/Kiev' => '+2:00',
 410              'Europe/Lisbon' => '+0.0',
 411              'Europe/Ljubljana' => '-11:00',
 412              'Europe/London' => '+0.0',
 413              'Europe/Luxembourg' => '-11:00',
 414              'Europe/Madrid' => '-11:00',
 415              'Europe/Malta' => '-11:00',
 416              'Europe/Minsk' => '+2:00',
 417              'Europe/Monaco' => '-11:00',
 418              'Europe/Moscow' => '+3:00',
 419              'Europe/Nicosia' => '+2:00',
 420              'Europe/Oslo' => '-11:00',
 421              'Europe/Paris' => '-11:00',
 422              'Europe/Prague' => '-11:00',
 423              'Europe/Riga' => '+2:00',
 424              'Europe/Rome' => '-11:00',
 425              'Europe/Samara' => '+4:00',
 426              'Europe/San_Marino' => '-11:00',
 427              'Europe/Sarajevo' => '-11:00',
 428              'Europe/Simferopol' => '+2:00',
 429              'Europe/Skopje' => '-11:00',
 430              'Europe/Sofia' => '+2:00',
 431              'Europe/Stockholm' => '-11:00',
 432              'Europe/Tallinn' => '+2:00',
 433              'Europe/Tirane' => '-11:00',
 434              'Europe/Tiraspol' => '+2:00',
 435              'Europe/Uzhgorod' => '+2:00',
 436              'Europe/Vaduz' => '-11:00',
 437              'Europe/Vatican' => '-11:00',
 438              'Europe/Vienna' => '-11:00',
 439              'Europe/Vilnius' => '+2:00',
 440              'Europe/Warsaw' => '-11:00',
 441              'Europe/Zagreb' => '-11:00',
 442              'Europe/Zaporozhye' => '+2:00',
 443              'Europe/Zurich' => '-11:00',
 444              'GB' => '+0.0',
 445              'GB-Eire' => '+0.0',
 446              'GMT' => '+0.0',
 447              'GMT0' => '+0.0',
 448              '+1:00' => '-11:00',
 449              '-4:00' => '-3:30',
 450              '-9:00' => '-8:00',
 451              'Greenwich' => '+0.0',
 452              'Hongkong' => '+8:00',
 453              'HST' => '-10:00',
 454              'Iceland' => '+0.0',
 455              'IET' => '-5:00',
 456              'Indian/Antananarivo' => '+3:00',
 457              'Indian/Chagos' => '+6:00',
 458              'Indian/Christmas' => '+7:00',
 459              'Indian/Cocos' => '+6:30',
 460              'Indian/Comoro' => '+3:00',
 461              'Indian/Kerguelen' => '+5:00',
 462              'Indian/Mahe' => '+4:00',
 463              'Indian/Maldives' => '+5:00',
 464              'Indian/Mauritius' => '+4:00',
 465              'Indian/Mayotte' => '+3:00',
 466              'Indian/Reunion' => '+4:00',
 467              'Iran' => '+3:30',
 468              'Israel' => '+2:00',
 469              'IST' => '+5:30:',
 470              'Jamaica' => '-5:00',
 471              'Japan' => '+9:00',
 472              'JST' => '+9:00',
 473              'Libya' => '+2:00',
 474              'MET' => '-11:00',
 475              'Mexico/BajaNorte' => '-8:00',
 476              'Mexico/BajaSur' => '-7:00',
 477              'Mexico/General' => '-6:00',
 478              'MIT' => '-11:00',
 479              'MST' => '-7:00',
 480              'MST7MDT' => '-7:00',
 481              'Navajo' => '-7:00',
 482              'NET' => '+4:00',
 483              'Pacific/Apia' => '-11:00',
 484              'Pacific/Easter' => '-6:00',
 485              'Pacific/Efate' => '+11:00',
 486              'Pacific/Fakaofo' => '-10:00',
 487              'Pacific/Galapagos' => '-6:00',
 488              'Pacific/Gambier' => '-8:00',
 489              'Pacific/Guadalcanal' => '+11:00',
 490              'Pacific/Guam' => '+10:00',
 491              'Pacific/Honolulu' => '-10:00',
 492              'Pacific/Johnston' => '-10:00',
 493              'Pacific/Kosrae' => '+11:00',
 494              'Pacific/Marquesas' => '-9:30',
 495              'Pacific/Midway' => '-11:00',
 496              'Pacific/Niue' => '-11:00',
 497              'Pacific/Norfolk' => '+11:30',
 498              'Pacific/Noumea' => '+11:00',
 499              'Pacific/Pago_Pago' => '-11:00',
 500              'Pacific/Palau' => '+9:00',
 501              'Pacific/Pitcairn' => '-8:00',
 502              'Pacific/Ponape' => '+11:00',
 503              'Pacific/Port_Moresby' => '+10:00',
 504              'Pacific/Rarotonga' => '-10:00',
 505              'Pacific/Saipan' => '+10:00',
 506              'Pacific/Samoa' => '-11:00',
 507              'Pacific/Tahiti' => '-10:00',
 508              'Pacific/Truk' => '+10:00',
 509              'Pacific/Yap' => '+10:00',
 510              'PLT' => '+5:00',
 511              'PNT' => '-7:00',
 512              'Poland' => '-11:00',
 513              'Portugal' => '+0.0',
 514              'PRC' => '+8:00',
 515              'PRT' => '-3:30',
 516              'PST' => '-8:00',
 517              'PST8PDT' => '-8:00',
 518              'ROK' => '+9:00',
 519              'Singapore' => '+8:00',
 520              'SST' => '+11:00',
 521              'SystemV/AST4' => '-3:30',
 522              'SystemV/AST4ADT' => '-3:30',
 523              'SystemV/CST6' => '-6:00',
 524              'SystemV/CST6CDT' => '-6:00',
 525              'SystemV/EST5' => '-5:00',
 526              'SystemV/EST5EDT' => '-5:00',
 527              'SystemV/HST10' => '-10:00',
 528              'SystemV/MST7' => '-7:00',
 529              'SystemV/MST7MDT' => '-7:00',
 530              'SystemV/PST8' => '-8:00',
 531              'SystemV/PST8PDT' => '-8:00',
 532              'SystemV/YST9' => '-8:00',
 533              'SystemV/YST9YDT' => '-8:00',
 534              'Turkey' => '+2:00',
 535              'UCT' => '+0.0',
 536              'Universal' => '+0.0',
 537              'US/Alaska' => '-8:00',
 538              'US/Aleutian' => '-10:00',
 539              'US/Arizona' => '-7:00',
 540              'US/Central' => '-6:00',
 541              'US/Eastern' => '-5:00',
 542              'US/East-Indiana' => '-5:00',
 543              'US/Hawaii' => '-10:00',
 544              'US/Indiana-Starke' => '-5:00',
 545              'US/Michigan' => '-5:00',
 546              'US/Mountain' => '-7:00',
 547              'US/Pacific' => '-8:00',
 548              'US/Pacific-New' => '-8:00',
 549              'US/Samoa' => '-11:00',
 550              'UTC' => '+0.0',
 551              'VST' => '+7:00',
 552              'WET' => '+0.0',
 553              'W-SU' => '+3:00',
 554              'Zulu' => '+0.0',
 555              'GMT-11:00' => '-11:00',
 556              'GMT-3:30' => '-3:30',
 557              'GMT-3:30' => '-3:30',
 558              'GMT-5:00' => '-5:00',
 559              'GMT-7:00' => '-7:00',
 560              'GMT-8:00' => '-8:00'
 561          );
 562          var $tz_offset;
 563          var $days = Array();
 564          var $days_short = Array();
 565          var $gmtnow = 0;
 566          var $users_localtime;
 567          var $cv_gmtdate;
 568  
 569          /**
 570           * Calling the constructor of the renamed class
 571           *
 572           * @return egw_datetime
 573           */
 574  		function datetime()
 575          {
 576              return $this->egw_datetime();
 577          }
 578  
 579          /**
 580           * Constructor of the renamed class
 581           *
 582           * @return egw_datetime
 583           */
 584  		function egw_datetime()
 585          {
 586              $this->tz_offset = 3600 * (int)@$GLOBALS['egw_info']['user']['preferences']['common']['tz_offset'];
 587              print_debug('datetime::datetime::gmtnow',$this->gmtnow,'api');
 588  
 589              $error_occured = True;
 590              // If we already have a GMT time, no need to do this again.
 591              if(!$this->gmtnow)
 592              {
 593                  if(isset($GLOBALS['egw_info']['server']['tz_offset']))
 594                  {
 595                      $this->gmtnow = time() - ((int)$GLOBALS['egw_info']['server']['tz_offset'] * 3600);
 596                      print_debug('datetime::datetime::tz_offset',"set via tz_offset=".$GLOBALS['egw_info']['server']['tz_offset'].": gmtnow=".date('Y/m/d H:i',$this->gmtnow),'api');
 597                  }
 598                  else
 599                  {
 600                      $this->gmtnow = time() - ($this->getbestguess() * 3600);
 601                      print_debug('datetime::datetime::bestguess',"set via bestguess=".$this->getbestguess().": gmtnow=".date('Y/m/d H:i',$this->gmtnow),'api');
 602                  }
 603              }
 604              $this->users_localtime = time() + $this->tz_offset;
 605          }
 606          
 607  		function getntpoffset()
 608          {
 609              $error_occured = False;
 610              if(!@is_object($GLOBALS['egw']->network))
 611              {
 612                  $GLOBALS['egw']->network = createobject('phpgwapi.network');
 613              }
 614              $server_time = time();
 615  
 616              if($GLOBALS['egw']->network->open_port('129.6.15.28',13,5))
 617              {
 618                  $line = $GLOBALS['egw']->network->bs_read_port(64);
 619                  $GLOBALS['egw']->network->close_port();
 620  
 621                  $array = explode(' ',$line);
 622                  // host: 129.6.15.28
 623                  // Value returned is 52384 02-04-20 13:55:29 50 0 0   9.2 UTC(NIST) *
 624                  print_debug('Server datetime',time(),'api');
 625                  print_debug('Temporary NTP datetime',$line,'api');
 626                  if ($array[5] == 4)
 627                  {
 628                      $error_occured = True;
 629                  }
 630                  else
 631                  {
 632                      $date = explode('-',$array[1]);
 633                      $time = explode(':',$array[2]);
 634                      $this->gmtnow = mktime((int)$time[0],(int)$time[1],(int)$time[2],(int)$date[1],(int)$date[2],(int)$date[0] + 2000);
 635                      print_debug('Temporary RFC epoch',$this->gmtnow,'api');
 636                      print_debug('GMT',date('Ymd H:i:s',$this->gmtnow),'api');
 637                  }
 638              }
 639              else
 640              {
 641                  $error_occured = True;
 642              }
 643  
 644              if($error_occured == True)
 645              {
 646                  return $this->getbestguess();
 647              }
 648              else
 649              {
 650                  return (int)(($server_time - $this->gmtnow) / 3600);
 651              }
 652          }
 653  
 654  		function gethttpoffset()
 655          {
 656              $error_occured = False;
 657              if(!@is_object($GLOBALS['egw']->network))
 658              {
 659                  $GLOBALS['egw']->network = createobject('phpgwapi.network');
 660              }
 661              $server_time = time();
 662  
 663              $filename = 'http://132.163.4.213/timezone.cgi?GMT';
 664              $file = $GLOBALS['egw']->network->gethttpsocketfile($filename);
 665              if(!$file)
 666              {
 667                  return $this->getbestguess();
 668              }
 669              $time = strip_tags($file[55]);
 670              $date = strip_tags($file[56]);
 671  
 672              print_debug('GMT DateTime',$date.' '.$time,'api');
 673              $dt_array = explode(' ',$date);
 674              $temp_datetime = $dt_array[0].' '.substr($dt_array[2],0,-1).' '.substr($dt_array[1],0,3).' '.$dt_array[3].' '.$time.' GMT';
 675              print_debug('Reformulated GMT DateTime',$temp_datetime,'api');
 676              $this->gmtnow = $this->convert_rfc_to_epoch($temp_datetime);
 677              print_debug('this->gmtnow',$this->gmtnow,'api');
 678              print_debug('server time',$server_time,'api');
 679              print_debug('server DateTime',date('D, d M Y H:i:s',$server_time),'api');
 680              return (int)(($server_time - $this->gmtnow) / 3600);
 681          }
 682  
 683  		function getbestguess()
 684          {
 685              print_debug('datetime::datetime::debug: Inside getting from local server','api');
 686              $server_time = time();
 687              // Calculate GMT time...
 688              // If DST, add 1 hour...
 689              //  - (date('I') == 1?3600:0)
 690              $this->gmtnow = $this->convert_rfc_to_epoch(gmdate('D, d M Y H:i:s',$server_time).' GMT');
 691              return (int)(($server_time - $this->gmtnow) / 3600);
 692          }
 693  
 694  		function convert_rfc_to_epoch($date_str)
 695          {
 696              $comma_pos = strpos($date_str,',');
 697              if($comma_pos)
 698              {
 699                  $date_str = substr($date_str,$comma_pos+1);
 700              }
 701  
 702              // This may need to be a reference to the different months in native tongue....
 703              $month = array(
 704                  'Jan' => 1,
 705                  'Feb' => 2,
 706                  'Mar' => 3,
 707                  'Apr' => 4,
 708                  'May' => 5,
 709                  'Jun' => 6,
 710                  'Jul' => 7,
 711                  'Aug' => 8,
 712                  'Sep' => 9,
 713                  'Oct' => 10,
 714                  'Nov' => 11,
 715                  'Dec' => 12
 716              );
 717              $dta = array();
 718              $ta = array();
 719  
 720              // Convert "15 Jul 2000 20:50:22 +0200" to unixtime
 721              $dta = explode(' ',$date_str);
 722              $ta = explode(':',$dta[4]);
 723  
 724              if(substr($dta[5],0,3) <> 'GMT')
 725              {
 726                  $tzoffset = substr($dta[5],0,1);
 727                  $tzhours = (int)substr($dta[5],1,2);
 728                  $tzmins = (int)substr($dta[5],3,2);
 729                  switch ($tzoffset)
 730                  {
 731                      case '-':
 732                          (int)$ta[0] += $tzhours;
 733                          (int)$ta[1] += $tzmins;
 734                          break;
 735                      case '+':
 736                          (int)$ta[0] -= $tzhours;
 737                          (int)$ta[1] -= $tzmins;
 738                          break;
 739                  }
 740              }
 741              return mktime($ta[0],$ta[1],$ta[2],$month[$dta[2]],$dta[1],$dta[3]);
 742          }
 743  
 744  		function get_weekday_start($year,$month,$day)
 745          {
 746              $weekday = $this->day_of_week($year,$month,$day);
 747              switch($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts'])
 748              {
 749                  // Saturday is for arabic support
 750                  case 'Saturday':
 751                      $this->days = Array(
 752                          0 => 'Sat',
 753                          1 => 'Sun',
 754                          2 => 'Mon',
 755                          3 => 'Tue',
 756                          4 => 'Wed',
 757                          5 => 'Thu',
 758                          6 => 'Fri'
 759                      );
 760                      $this->days_short = Array(
 761                          0 => 'Sa',
 762                          1 => 'Su',
 763                          2 => 'Mo',
 764                          3 => 'Tu',
 765                          4 => 'We',
 766                          5 => 'Th',
 767                          6 => 'Fr'
 768                      );
 769                      switch($weekday)
 770                      {
 771                          case 0:
 772                              $sday = mktime(2,0,0,$month,$day - 1,$year);
 773                              break;
 774                          case 6:
 775                              $sday = mktime(2,0,0,$month,$day,$year);
 776                              break;
 777                          default:
 778                              $sday = mktime(2,0,0,$month,$day - ($weekday + 1),$year);
 779                              break;
 780                      }
 781                      break;
 782                  case 'Monday':
 783                      $this->days = Array(
 784                          0 => 'Mon',
 785                          1 => 'Tue',
 786                          2 => 'Wed',
 787                          3 => 'Thu',
 788                          4 => 'Fri',
 789                          5 => 'Sat',
 790                          6 => 'Sun'
 791                      );
 792                      $this->days_short = Array(
 793                          0 => 'Mo',
 794                          1 => 'Tu',
 795                          2 => 'We',
 796                          3 => 'Th',
 797                          4 => 'Fr',
 798                          5 => 'Sa',
 799                          6 => 'Su'
 800                      );
 801                      switch($weekday)
 802                      {
 803                          case 0:
 804                              $sday = mktime(2,0,0,$month,$day - 6,$year);
 805                              break;
 806                          case 1:
 807                              $sday = mktime(2,0,0,$month,$day,$year);
 808                              break;
 809                          default:
 810                              $sday = mktime(2,0,0,$month,$day - ($weekday - 1),$year);
 811                              break;
 812                      }
 813                      break;
 814                  case 'Sunday':
 815                  default:
 816                      $this->days = Array(
 817                          0 => 'Sun',
 818                          1 => 'Mon',
 819                          2 => 'Tue',
 820                          3 => 'Wed',
 821                          4 => 'Thu',
 822                          5 => 'Fri',
 823                          6 => 'Sat'
 824                      );
 825                      $this->days_short = Array(
 826                          0 => 'Su',
 827                          1 => 'Mo',
 828                          2 => 'Tu',
 829                          3 => 'We',
 830                          4 => 'Th',
 831                          5 => 'Fr',
 832                          6 => 'Sa'
 833                      );
 834                      $sday = mktime(2,0,0,$month,$day - $weekday,$year);
 835                      break;
 836              }
 837              return $sday - 7200;
 838          }
 839  
 840  		function is_leap_year($year)
 841          {
 842              if (((int)$year % 4 == 0) && ((int)$year % 100 != 0) || ((int)$year % 400 == 0))
 843              {
 844                  return 1;
 845              }
 846              else
 847              {
 848                  return 0;
 849              }
 850          }
 851  
 852  		function days_in_month($month,$year)
 853          {
 854              $days = Array(
 855                  1  => 31,
 856                  2  => 28 + $this->is_leap_year((int)$year),
 857                  3  => 31,
 858                  4  => 30,
 859                  5  => 31,
 860                  6  => 30,
 861                  7  => 31,
 862                  8  => 31,
 863                  9  => 30,
 864                  10 => 31,
 865                  11 => 30,
 866                  12 => 31
 867              );
 868              return $days[(int)$month];
 869          }
 870  
 871  		function date_valid($year,$month,$day)
 872          {
 873              return checkdate((int)$month,(int)$day,(int)$year);
 874          }
 875  
 876  		function time_valid($hour,$minutes,$seconds)
 877          {
 878              if((int)$hour < 0 || (int)$hour > 24)
 879              {
 880                  return False;
 881              }
 882              if((int)$minutes < 0 || (int)$minutes > 59)
 883              {
 884                  return False;
 885              }
 886              if((int)$seconds < 0 || (int)$seconds > 59)
 887              {
 888                  return False;
 889              }
 890  
 891              return True;
 892          }
 893  
 894  		function day_of_week($year,$month,$day)
 895          {
 896              if($month > 2)
 897              {
 898                  $month -= 2;
 899              }
 900              else
 901              {
 902                  $month += 10;
 903                  $year--;
 904              }
 905              $day = (floor((13 * $month - 1) / 5) + $day + ($year % 100) + floor(($year % 100) / 4) + floor(($year / 100) / 4) - 2 * floor($year / 100) + 77);
 906              return (($day - 7 * floor($day / 7)));
 907          }
 908  
 909  		function day_of_year($year,$month,$day)
 910          {
 911              $days = array(0,31,59,90,120,151,181,212,243,273,304,334);
 912  
 913              $julian = ($days[$month - 1] + $day);
 914  
 915              if($month > 2 && $this->is_leap_year($year))
 916              {
 917                  $julian++;
 918              }
 919              return($julian);
 920          }
 921  
 922          /*!
 923          @function days_between
 924          @abstract Get the number of days between two dates
 925          @author Steven Cramer/Ralf Becker
 926          @param $m1 - Month_1, $d1 - Day_1, $y1 - Year_1, $m2 - Month_2, $d2 - Day_2, $y2 - Year_2
 927          @note the last param == 0, ensures that the calculation is always done without daylight-saveing
 928          */
 929  		function days_between($m1,$d1,$y1,$m2,$d2,$y2)
 930          {
 931              return (int)((mktime(0,0,0,$m2,$d2,$y2,0) - mktime(0,0,0,$m1,$d1,$y1,0)) / 86400);
 932          }
 933  
 934  		function date_compare($a_year,$a_month,$a_day,$b_year,$b_month,$b_day)
 935          {
 936              $a_date = mktime(0,0,0,(int)$a_month,(int)$a_day,(int)$a_year);
 937              $b_date = mktime(0,0,0,(int)$b_month,(int)$b_day,(int)$b_year);
 938              if($a_date == $b_date)
 939              {
 940                  return 0;
 941              }
 942              elseif($a_date > $b_date)
 943              {
 944                  return 1;
 945              }
 946              elseif($a_date < $b_date)
 947              {
 948                  return -1;
 949              }
 950          }
 951  
 952  		function time_compare($a_hour,$a_minute,$a_second,$b_hour,$b_minute,$b_second)
 953          {
 954              // I use the 1970/1/2 to compare the times, as the 1. can get via TZ-offest still
 955              // before 1970/1/1, which is the earliest date allowed on windows
 956              $a_time = mktime((int)$a_hour,(int)$a_minute,(int)$a_second,1,2,1970);
 957              $b_time = mktime((int)$b_hour,(int)$b_minute,(int)$b_second,1,2,1970);
 958              if($a_time == $b_time)
 959              {
 960                  return 0;
 961              }
 962              elseif($a_time > $b_time)
 963              {
 964                  return 1;
 965              }
 966              elseif($a_time < $b_time)
 967              {
 968                  return -1;
 969              }
 970          }
 971  
 972  		function makegmttime($hour,$minute,$second,$month,$day,$year)
 973          {
 974              return $this->gmtdate(mktime($hour, $minute, $second, $month, $day, $year));
 975          }
 976  
 977          // Note common:show_date converts server- to user-time, before it returns the requested format !!!
 978  		function localdates($localtime)
 979          {
 980              $date = Array('raw','day','month','year','full','dow','dm','bd');
 981              $date['raw'] = $localtime;
 982              $date['year'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'Y');
 983              $date['month'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'m');
 984              $date['day'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'d');
 985              $date['full'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'Ymd');
 986              $date['bd'] = mktime(0,0,0,$date['month'],$date['day'],$date['year']);
 987              $date['dm'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'dm');
 988              $date['dow'] = $this->day_of_week($date['year'],$date['month'],$date['day']);
 989              $date['hour'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'H');
 990              $date['minute'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'i');
 991              $date['second'] = (int)$GLOBALS['egw']->common->show_date($date['raw'],'s');
 992  
 993              return $date;
 994          }
 995  
 996  		function gmtdate($localtime)
 997          {
 998              return $this->localdates($localtime - $this->tz_offset);
 999          }
1000      }
1001  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7