PageSourceSearch

https://www.gites-de-france-22-35-56.fr/lib_2/js/obj/OBJDate.js

js gites-de-france-22-35-56.fr collected 2026-10-07 13:38:46 UTC 14,977 bytes, 584 lines download raw bytes

1function OBJDate(chaine){
2
3	this.jour=null;
4	this.mois=null; 
5	this.annee=null;
6	
7	this.str = null;
8	
9	OBJDate.prototype.definition = function(str){
10		
11		if (!str){
12			var dte= new Date();
13			var str = dte.getDate()+"/"+(dte.getMonth()+1)+"/"+dte.getFullYear();
14		}
15		
16		str = new String(str);
17		if (str.length==6){
18			this.jour=str.substr(0,2);
19			this.mois=str.substr(2,2);
20			this.annee="20"+str.substr(4,2);
21		}else{
22			tab=str.split("/");
23			if (!tab[1] || tab[1].length==0){
24				tab=str.split("-");
25				if (!tab[1] || tab[1].length==0){
26					tab=str.split(".");
27					if (!tab[1] || tab[1].length==0){
28						tab[0]=str.substr(0,2);
29						tab[1]=str.substr(2,2);
30						tab[2]=str.substr(4,4);
31					}
32				}
33			}
34			if (tab[2].length==2)tab[2]=parseInt(2000+Number(tab[2]));
35			
36			this.str=new String(str);
37			this.jour=tab[0];
38			this.mois=tab[1];
39			this.annee=tab[2];
40		}
41	
42	};
43        this.definition(chaine);
44	
45	OBJDate.prototype.setDateByInfos = function(j,m,a){
46		this.jour=j;
47		this.mois=m;
48		this.annee=a;
49	};
50    OBJDate.prototype.getProchainSamedi = function () {
51        while (this.getJourSemaine() !== 5) {
52            this.ajoutJour(1);
53        }
54        this.ajoutJour(1);
55        return this;
56    };
57	
58	OBJDate.prototype.ajoutJour = function(nbj){
59		var msPerDay = 24 * 60 * 60 * 1000;
60		var quatreheurePourChgtHr= 4 * 60 * 60 * 1000;
61		
62		var d=Date.UTC(this.annee,(Number(this.mois)-1),this.jour);
63		
64		var d=Date.parse(Number(this.mois)+"/"+this.jour+"/"+this.annee);
65		var d2=parseInt(d+(Number(nbj)*msPerDay) + quatreheurePourChgtHr);
66		
67		var dte = new Date();
68		dte.setTime(d2);
69		
70		this.jour=dte.getDate();
71		this.mois=dte.getMonth()+1;
72		this.annee=dte.getFullYear();
73	};
74
75    OBJDate.prototype.enleveJour = function(nbj){
76		var msPerDay = 24 * 60 * 60 * 1000;
77		var quatreheurePourChgtHr= 4 * 60 * 60 * 1000;
78
79		var d=Date.UTC(this.annee,(Number(this.mois)-1),this.jour);
80
81		var d=Date.parse(Number(this.mois)+"/"+this.jour+"/"+this.annee);
82		var d2=parseInt(d-(Number(nbj)*msPerDay) + quatreheurePourChgtHr);
83
84		var dte = new Date();
85		dte.setTime(d2);
86
87		this.jour=dte.getDate();
88		this.mois=dte.getMonth()+1;
89		this.annee=dte.getFullYear();
90	};
91	
92	OBJDate.prototype.getMoisSuivant = function(){
93		if (this.mois == 12){this.mois=1;this.annee++;}
94		else this.mois++;
95	};
96	
97	OBJDate.prototype.getMoisPrecedent = function(){
98		if (this.mois == 1){this.mois=12;this.annee--;}
99		else this.mois--;
100	};
101
102	OBJDate.prototype.estMoisCourant = function(){	
103		var dte=new Date();
104		return (this.mois==(dte.getMonth()+1));
105	};
106
107	OBJDate.prototype.estAnneeCourante = function(){
108		var dte=new Date();
109		return (this.annee==dte.getFullYear());
110	};
111	
112	OBJDate.prototype.ajoutMois = function(nb){
113		if(nb<0)this.retireMois(nb*(-1));
114		else {
115			for(var i=1;i<=nb;i++){
116				this.getMoisSuivant();
117			}
118		}
119	};
120	
121	OBJDate.prototype.retireMois = function(nb){
122		for(var i=1;i<=nb;i++){
123			this.getMoisPrecedent();
124		}		
125	};
126
127	OBJDate.prototype.getJour = function(){
128		//if(this.jour.length==1) this.jour = "0"+this.jour;
129		return this.jour;
130	};
131	OBJDate.prototype.getMois = function(){
132		//if(this.mois.length==1) this.mois = "0"+this.mois;
133		return this.mois;
134	};
135	OBJDate.prototype.getAnnee = function(){
136		return this.annee;
137	};
138
139	OBJDate.prototype.getLibelleJour = function(){
140		var tabJ= new Array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi");
141		return tabJ[this.getJourSemaine()];
142	};
143	
144	OBJDate.prototype.getJourSemaine=function(){
145		return new Date(this.mois+"/"+this.jour+"/"+this.annee).getDay();
146	};
147	OBJDate.prototype.getJSONLblJourWeek = function(langue) {
148		var tabJr;
149		switch(langue){
150			case "ANGLAIS":
151				tabJr = [{"libelle":"Sunday","libelle_court":"Su"},
152						 {"libelle":"Monday","libelle_court":"Mo"},
153						 {"libelle":"Tuesday","libelle_court":"Tu"},
154						 {"libelle":"Wednesday","libelle_court":"We"},
155						 {"libelle":"Thursday","libelle_court":"Th"},
156						 {"libelle":"Friday","libelle_court":"Fr"},
157						 {"libelle":"Saturday","libelle_court":"Sa"}];
158				break; 
159				
160			case "ALLEMAND":
161				tabJr = [{"libelle":"Sonntag","libelle_court":"So"},
162						 {"libelle":"Montag","libelle_court":"Mo"},
163						 {"libelle":"Dienstag","libelle_court":"Di"},
164						 {"libelle":"Mittwoch","libelle_court":"Mi"},
165						 {"libelle":"Donnerstag","libelle_court":"Do"},
166						 {"libelle":"Freitag","libelle_court":"Fr"},
167						 {"libelle":"Samstag","libelle_court":"Sa"}];
168				break; 
169				
170			case "HOLLANDAIS":
171            case "NEERLANDAIS":
172				tabJr = [{"libelle":"Zondag","libelle_court":"Zo"},
173						 {"libelle":"Maandag","libelle_court":"Ma"},
174						 {"libelle":"Dinsdag","libelle_court":"Di"},
175						 {"libelle":"Woensdag","libelle_court":"Wo"},
176						 {"libelle":"Donderdag","libelle_court":"Do"},
177						 {"libelle":"Vrijdag","libelle_court":"Vr"},
178						 {"libelle":"Zaterdag","libelle_court":"Za"}];
179				break; 
180				
181			case "ESPAGNOL":
182				tabJr = [{"libelle":"Domingo","libelle_court":"Do"},
183						 {"libelle":"Lunes","libelle_court":"Lu"},
184						 {"libelle":"Martes","libelle_court":"Ma"},
185						 {"libelle":"Mi&eacute;rcoles","libelle_court":"Mi"},
186						 {"libelle":"Jueves","libelle_court":"Ju"},
187						 {"libelle":"Viernes","libelle_court":"Vi"},
188						 {"libelle":"S&aacute;bado","libelle_court":"S&aacute;"}];
189				break; 
190				
191			case "ITALIEN":
192				tabJr = [{"libelle":"Domenica","libelle_court":"Do"},
193						 {"libelle":"Lunedì","libelle_court":"Lu"},
194						 {"libelle":"Martedì","libelle_court":"Ma"},
195						 {"libelle":"Mercoledì","libelle_court":"Me"},
196						 {"libelle":"Giovedì","libelle_court":"Gi"},
197						 {"libelle":"Venerdì","libelle_court":"Ve"},
198						 {"libelle":"Sabato","libelle_court":"Sa"}];
199				break; 
200                
201			case "PORTUGAIS":
202				tabJr = [{"libelle":"Domingo","libelle_court":"Do"},
203						 {"libelle":"Segunda-feira","libelle_court":"Se"},
204						 {"libelle":"Ter&ccedil;a-feira","libelle_court":"Te"},
205						 {"libelle":"Quarta-feira","libelle_court":"Qu"},
206						 {"libelle":"Quinta-feira","libelle_court":"Qu"},
207						 {"libelle":"Sexta-feira","libelle_court":"Se"},
208						 {"libelle":"S&aacute;bado","libelle_court":"S&aacute;"}];
209				break; 
210            
211			case "FRANCAIS":
212			default:
213				tabJr = [{"libelle":"Dimanche","libelle_court":"Di"},
214						 {"libelle":"Lundi","libelle_court":"Lu"},
215						 {"libelle":"Mardi","libelle_court":"Ma"},
216						 {"libelle":"Mercredi","libelle_court":"Me"},
217						 {"libelle":"Jeudi","libelle_court":"Je"},
218						 {"libelle":"Vendredi","libelle_court":"Ve"},
219						 {"libelle":"Samedi","libelle_court":"Sa"}];
220				break; 
221		}
222		
223		return tabJr;
224	};
225	
226	OBJDate.prototype.getTabMois = function(langue){
227		var tabM= new Array();
228		
229		switch(langue){
230			case "ANGLAIS":
231				tabM[1]="January";
232				tabM[2]="February";
233				tabM[3]="March";
234				tabM[4]="April";
235				tabM[5]="May";
236				tabM[6]="June";
237				tabM[7]="July";
238				tabM[8]="August";
239				tabM[9]="September";
240				tabM[10]="October";
241				tabM[11]="November";
242				tabM[12]="December";
243				break;
244			
245			case "ALLEMAND":
246				tabM[1]="Januar";
247				tabM[2]="Februar";
248				tabM[3]="M&auml;rz";
249				tabM[4]="April";
250				tabM[5]="Mai";
251				tabM[6]="Juni";
252				tabM[7]="Juli";
253				tabM[8]="August";
254				tabM[9]="September";
255				tabM[10]="Oktober";
256				tabM[11]="November";
257				tabM[12]="Dezember";
258				break;
259			
260			case "HOLLANDAIS":
261            case "NEERLANDAIS":
262				tabM[1]="Januari";
263				tabM[2]="Februari";
264				tabM[3]="Maart";
265				tabM[4]="April";
266				tabM[5]="Mei";
267				tabM[6]="Juni";
268				tabM[7]="Juli";
269				tabM[8]="Augustus";
270				tabM[9]="September";
271				tabM[10]="Oktober";
272				tabM[11]="November ";
273				tabM[12]="December";
274				break;
275			
276			case "ESPAGNOL":
277				tabM[1]="Eenero ";
278				tabM[2]="Ebrero";
279				tabM[3]="Marzo";
280				tabM[4]="Abril";
281				tabM[5]="Mayo";
282				tabM[6]="Junio";
283				tabM[7]="Julio";
284				tabM[8]="Agosto";
285				tabM[9]="Septiembre";
286				tabM[10]="Octubre";
287				tabM[11]="Noviembre ";
288				tabM[12]="Diciembre";
289				break;
290			
291			case "ITALIEN":
292				tabM[1]="Gennaio";
293				tabM[2]="Febbraio";
294				tabM[3]="Marzo";
295				tabM[4]="Aprile";
296				tabM[5]="Maggio";
297				tabM[6]="Giugno";
298				tabM[7]="Luglio";
299				tabM[8]="Agosto";
300				tabM[9]="Settembre";
301				tabM[10]="Ottobre";
302				tabM[11]="Novembre ";
303				tabM[12]="Dicembre";
304				break;
305                
306            case "PORTUGAIS":
307				tabM[1]="Janeiro";
308				tabM[2]="Fevereiro";
309				tabM[3]="Mar&ccedil;o";
310				tabM[4]="Abril";
311				tabM[5]="Maio";
312				tabM[6]="Junho";
313				tabM[7]="Julho";
314				tabM[8]="Agosto";
315				tabM[9]="Setembro";
316				tabM[10]="Outubro";
317				tabM[11]="Novembro";
318				tabM[12]="Dezembro";
319				break;
320			
321			case "FRANCAIS":
322			default:
323				tabM[1]="Janvier";
324				tabM[2]="F&eacute;vrier";
325				tabM[3]="Mars";
326				tabM[4]="Avril";
327				tabM[5]="Mai";
328				tabM[6]="Juin";
329				tabM[7]="Juillet";
330				tabM[8]="Aout";
331				tabM[9]="Septembre";
332				tabM[10]="Octobre";
333				tabM[11]="Novembre";
334				tabM[12]="D&eacute;cembre";
335				break;
336		}
337		return tabM;
338	};
339    
340    OBJDate.prototype.getTabMoisCourt = function(langue){
341		var tabM= new Array();
342		
343		switch(langue){
344			case "ANGLAIS":
345				tabM[1]="January";
346				tabM[2]="February";
347				tabM[3]="March";
348				tabM[4]="April";
349				tabM[5]="May";
350				tabM[6]="June";
351				tabM[7]="July";
352				tabM[8]="August";
353				tabM[9]="September";
354				tabM[10]="October";
355				tabM[11]="November";
356				tabM[12]="December";
357				break;
358			
359			case "ALLEMAND":
360				tabM[1]="Januar";
361				tabM[2]="Februar";
362				tabM[3]="M&auml;rz";
363				tabM[4]="April";
364				tabM[5]="Mai";
365				tabM[6]="Juni";
366				tabM[7]="Juli";
367				tabM[8]="August";
368				tabM[9]="September";
369				tabM[10]="Oktober";
370				tabM[11]="November";
371				tabM[12]="Dezember";
372				break;
373			
374			case "HOLLANDAIS":
375            case "NEERLANDAIS":
376				tabM[1]="Januari";
377				tabM[2]="Februari";
378				tabM[3]="Maart";
379				tabM[4]="April";
380				tabM[5]="Mei";
381				tabM[6]="Juni";
382				tabM[7]="Juli";
383				tabM[8]="Augustus";
384				tabM[9]="September";
385				tabM[10]="Oktober";
386				tabM[11]="November ";
387				tabM[12]="December";
388				break;
389			
390			case "ESPAGNOL":
391				tabM[1]="Eenero ";
392				tabM[2]="Ebrero";
393				tabM[3]="Marzo";
394				tabM[4]="Abril";
395				tabM[5]="Mayo";
396				tabM[6]="Junio";
397				tabM[7]="Julio";
398				tabM[8]="Agosto";
399				tabM[9]="Septiembre";
400				tabM[10]="Octubre";
401				tabM[11]="Noviembre ";
402				tabM[12]="Diciembre";
403				break;
404			
405			case "ITALIEN":
406				tabM[1]="Gennaio";
407				tabM[2]="Febbraio";
408				tabM[3]="Marzo";
409				tabM[4]="Aprile";
410				tabM[5]="Maggio";
411				tabM[6]="Giugno";
412				tabM[7]="Luglio";
413				tabM[8]="Agosto";
414				tabM[9]="Settembre";
415				tabM[10]="Ottobre";
416				tabM[11]="Novembre ";
417				tabM[12]="Dicembre";
418				break;
419                
420            case "PORTUGAIS":
421				tabM[1]="Janeiro";
422				tabM[2]="Fevereiro";
423				tabM[3]="Mar&ccedil;o";
424				tabM[4]="Abril";
425				tabM[5]="Maio";
426				tabM[6]="Junho";
427				tabM[7]="Julho";
428				tabM[8]="Agosto";
429				tabM[9]="Setembro";
430				tabM[10]="Outubro";
431				tabM[11]="Novembro";
432				tabM[12]="Dezembro";
433				break;
434			
435			case "FRANCAIS":
436			default:
437				tabM[1]="Janv.";
438				tabM[2]="F&eacute;v.";
439				tabM[3]="Mar.";
440				tabM[4]="Avr.";
441				tabM[5]="Mai";
442				tabM[6]="Juin";
443				tabM[7]="Juil.";
444				tabM[8]="Aout";
445				tabM[9]="Sept.";
446				tabM[10]="Oct.";
447				tabM[11]="Nov.";
448				tabM[12]="D&eacute;c.";
449				break;
450		}
451		return tabM;
452	};
453    
454	OBJDate.prototype.getLibelleMois = function(langue){
455		if(!langue) langue = "FRANCAIS";
456		var tabM=this.getTabMois(langue);
457		return  tabM[parseInt(this.getMois())];//pour lire la tableau TabMois, il faut un chiffre et pas un texte: '03' -> il faut un '3''
458	};
459	OBJDate.prototype.getLibelleMoisCourt = function(langue){
460		if(!langue) langue = "FRANCAIS";
461		var tabM=this.getTabMoisCourt(langue);
462		return  tabM[parseInt(this.getMois())];//pour lire la tableau TabMois, il faut un chiffre et pas un texte: '03' -> il faut un '3''
463	};
464
465    OBJDate.prototype.getDate = function(){
466        return this.toString('dd/mm/yyyy');
467    };
468    
469    
470    OBJDate.prototype.toMySQL = function(){
471        return this.toString('yyyy-mm-dd');
472    };
473
474	OBJDate.prototype.toString = function(format){
475		if(!format) format="dd/mm/yyyy";
476		
477		var jr = parseInt(this.getJour(),10);
478		var mois = parseInt(this.getMois(),10);
479		var j= new String((jr<10)?"0"+jr:jr);
480		var m= new String((mois<10)?"0"+mois:mois);
481		var a4 = new String(this.getAnnee());
482		var a2 = new String(parseInt((this.getAnnee()-2000),10));
483		
484		switch (format){
485		case "dd/mm/yyyy":
486			return (j+"/"+m+"/"+a4);
487		case "dd/mm/yy":
488			return (j+"/"+m+"/"+a2);
489		case "ddmmyyyy":
490			return (j+m+a4);
491		case "yyyymmdd":
492			return (a4+m+j);
493		case "yyyy-mm-dd":
494			return (a4+'-'+m+'-'+j);
495		case "ddmmyy":
496			return (j+m+a2);
497        case "dd.mm.yy":
498			return (j+'.'+m+'.'+a2);
499		case "dd":
500			return j;
501		default:
502			return (j+"/"+m+"/"+a4);
503		}
504	};
505
506
507
508	OBJDate.prototype.getNbjMois = function(){
509		return this.getNbjMoisAutre(this.mois);
510	};
511
512
513	OBJDate.prototype.getNbjMoisAutre = function(mois){
514		if (mois==1 || mois==3 || mois==5 || mois==7 || mois==8 || mois==10 || mois==12)
515			return 31;
516		if (mois==4 || mois==6 || mois==9 || mois==11)
517			return 30;
518		if (mois==2 && this.estBissextile(this.annee))return 29;
519		else return 28;
520	};
521
522	OBJDate.prototype.estBissextile = function(annee){
523		return (annee%4==0 && (annee%100!=0 || (annee%100==0 && annee%400==0)));
524	};
525
526
527	OBJDate.prototype.estAvant = function(dte){
528		obj=new OBJDate(dte);
529		return (this.getTimeStamp()<=obj.getTimeStamp());
530	};
531	
532	OBJDate.prototype.estAvantOBJDate = function(dte){
533		return (this.getTimeStamp()<=dte.getTimeStamp());
534	};
535	
536	OBJDate.prototype.estAvantStrictOBJDate = function(dte){
537		return (this.getTimeStamp()<dte.getTimeStamp());
538	};
539	
540	OBJDate.prototype.estEgale = function(dte){
541		obj=new OBJDate();
542		obj.definition(dte);
543		return (this.getTimeStamp()==obj.getTimeStamp());		
544	};
545	
546	OBJDate.prototype.estApres = function(dte){
547		obj=new OBJDate(dte);
548		return (this.getTimeStamp()>=obj.getTimeStamp());
549	};
550
551	OBJDate.prototype.estApresOBJDate = function(dte){
552		return (this.getTimeStamp()>=dte.getTimeStamp());
553	};
554
555	OBJDate.prototype.estApresStrictOBJDate = function(dte){
556		return (this.getTimeStamp()>dte.getTimeStamp());
557	};
558
559	OBJDate.prototype.estComprisEntre = function(dteDeb,dteFin){		
560		
561		return (this.estAvant(dteFin) && this.estApres(dteDeb));
562	};
563
564	OBJDate.prototype.getTimeStamp = function() {
565		return new Date(this.mois+"/"+this.jour+"/"+this.annee).getTime();
566	};
567
568	OBJDate.prototype.getNbJourEcartWithOBJDate = function(dte,positif) {
569		var nbj1 = this.getTimeStamp()/ 86400000;
570		var nbj2 = dte.getTimeStamp() / 86400000;                
571		var nbj = Math.round(nbj1 - nbj2);
572		if(positif!="N" && nbj<0) nbj = nbj * (-1);
573		return nbj;
574	};
575    
576    OBJDate.prototype.retireAnnee = function(nbAnnee){
577        this.annee = this.annee - nbAnnee;
578        return this;
579    };
580    OBJDate.prototype.ajouteAnnee = function (nbAnnee) {
581        this.annee = parseInt(this.annee) + parseInt(nbAnnee);
582        return this;
583    };
584}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.