Bonjour,

j'ai fait un petit script qui se sert de la fonction date_default_timezone_set implémentée par PHP5, tout marchait bien depuis début avril jusqu'à ce matin où le timezone "Europe/Paris" me retourne l'heure corrigée aulieu de l'heure sans DST (daylight saving time) comme il est dit dans la doc, ce qui fait que je me retrouve avec l'heure parisienne avec une heure en trop. C'est bizarre tous les autres timezone fonctionnent.

voilà le code de ville.php5, si quelqu'un a une idée, je prends

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
 
<?php
#***********************coded by mnem0 2007*******************************************
error_reporting(0);
 
 
class ville
{
 
		function ville($name,$dtz) # ville object constructor (you must provide the name and the dateTimeZone)
		{
			$this->name=$name; 
			$this->dtz=$dtz;
			date_default_timezone_set($this->dtz);
			$now=getDate();
			$this->hour = $now[hours];
			$this->minute = $now[minutes];
			$this->year = $now[year];
			$this->month=$now[month];
			$this->day=$now[day];
			$this->wday = $now[wday];
			$this->mday = $now[mday];
 
 
			########################
						switch($this->dtz)
						{
 
								case "America/Los_Angeles" : $this->isDSTed = true;break;
 
								case "America/New_York" : $this->isDSTed = true;break;
 
								case "Europe/London" : $this->isDSTed = true;break;
 
								case "Europe/Paris" : $this->isDSTed = true;break;
 
								case "Asia/Tokyo" : $this->isDSTed = false;break;
 
								case "Australia/Sydney" : $this->isDSTed = true;break;
 
								#feel free to add a dateTimeZone/town with its corresponding daylight saving time policy (i.e true or false)
 
								default : break;
							}
 
							####################### function that computes the day of the week and the occurence of this day in the current month
							#i.e posday [2][1] will be the 2nd 
							   $this->toyme =mktime(0, 0, 0, $this->month, $this->day, $this->year);
							   $this->mymonth = intval(date("m", $this->toyme)); 
							   $this->myday = intval(date("d", $this->toyme));
							   for ($i = 0; $i < 7; $i++) 
							   {
								   $this->days[] = date("l", mktime(0, 0, 0, $this->mymonth, ($i+1), date("Y", $this->toyme)));   
							   }
 
							   $this->posd  = array_search(date("l", $this->toyme), $this->days);
							   $this->posdm = array_search($this->days[0], $this->days) - $posd;
							   $this->posDay[0] =$this->posd;
							   $this->posDay[1] =$this->posm;	
				#1
				switch($this->month)
				{
					case "January" : 
 
					case "February" : if(!($this->dtz=="Australia/Sydney")){$actualDST=false;} else {$actualDST=true;} break;
 
					case "March" : switch($this->dtz)
					#2
									{
											case "Europe/London" : 
 
											case "Europe/Paris" : 
 
											case "Australia/Sydney" : if(($this->posDay[0]<3)||(($this->posDay[0]==3)&&($this->posDay[1]<7))||(31-$now[mday]<7-$now[wday]))
																		{
																			if(!($this->dtz=="Australia/Sydney")){$this->actualDST=false;} else {$this->actualDST=true;}
																		}
																		else
																		{
																			if(!($this->dtz=="Australia/Sydney")){$this->actualDST=true;} else {$this->actualDST=false;}
																		} break;
 
											case "America/Los_Angeles" : 
 
											case "America/New_York" :   
 
 
 
 
									#2		
									}
 
 
 
 
 
 
					case "April" : if(($this->posDay[0]<3)||(($this->posDay[0]==3)&&($this->posDay[1]<7))||(31-$now[mday]<7-$now[wday]))
																		{
																			$this->actualDST=false;
																		}
																		else
																		{
																			$this->actualDST=true;
																		} break;
 
 
					case "May" :
 
					case "Juny" :
 
					case "July" :
 
					case "August" :
 
					case "September" :
 
					case "October" : if($this->posDay[0]<3)
 
															switch($this->dtz)
															{
 
																case "America/Los_Angeles" : 
 
																case "America/New_York" :
 
																case "Europe/London" :
 
																case "Europe/Paris" : $this->actualDST = true;break; #jusqu'a octobre on est en heure +  1 = true de LA a Paris
 
																case "Asia/Tokyo" : break;# on ne calcule pas tokyo : n'a pas de politique de  DST
 
																case "Australia/Sydney" : $this->actualDST = false;break;#jusqu'a octobre on est en heure +  1 = False pour Sydney
 
																default : break;
															}
															else
																switch($this->dtz)
															{
 
																case "America/Los_Angeles" : 
 
																case "America/New_York" :
 
																case "Europe/London" :
 
																case "Europe/Paris" : $this->actualDST = false;break;
 
																case "Asia/Tokyo" : break;
 
																case "Australia/Sydney" : $this->actualDST = true;break;
 
																default : break;
															}  break;
 
					case "November" : 
 
					case "December" : switch($this->dtz)
															{
 
																case "America/Los_Angeles" : 
 
																case "America/New_York" :
 
																case "Europe/London" :
 
																case "Europe/Paris" : $this->actualDST = false;break;
 
																case "Asia/Tokyo" : break;
 
																case "Australia/Sydney" : $this->actualDST = true;break;
 
																default : break;
															} break;
										#1
									}
 
 
						if($this->isDSTed==true)#si l'objet courant a une politique DST
							{
								if($this->actualDST==true)#si l'heure courante = heure d'été
 
								{$this->hour++;echo("heure++ pour ".$this->name."<br />");}#alors on incremente de 1
							}
 
							if($this->minute<10)
							{	
								$corrigeMinute ="0".$this->minute;#quand les minutes sont inferieures à 10 on avait par exemple minute = 9, or on veut 09 à l'affichage
								$this->minute=$corrigeMinute;
							}
 
			######constructor		
		}	
#class		
}
$Tokyo = new ville("Tokyo","Asia/Tokyo");
$LA = new ville("Los_Angeles","America/Los_Angeles");
$Sydney = new ville("Sydney","Australia/Sydney");
$NY = new ville("New-York","America/New_York");
$Paris=new ville("Paris","Europe/Paris");
$Londres=new ville("Londres","Europe/London");
date_default_timezone_set("Europe/Paris");
$now=getDate();
echo("****".$now[hours]." : ".$now[minutes]."*******");
echo $Tokyo->name." ".$Tokyo->hour.":".$Tokyo->minute." DST : ".$Tokyo->isDSTed."<br />";
echo $NY->name." ".$NY->hour.":".$NY->minute." DST : ".$NY->isDSTed."<br />";
echo $LA->name." ".$LA->hour.":".$LA->minute." DST : ".$LA->isDSTed."<br />";
echo $Londres->name." ".$Londres->hour.":".$Londres->minute." DST : ".$Londres->isDSTed."<br />";
echo $Paris->name." ".$Paris->hour.":".$Paris->minute." DST : ".$Paris->isDSTed."<br />";
echo $Sydney->name." ".$Sydney->hour.":".$Sydney->minute." DST : ".$Sydney->isDSTed."<br />";
 
?>