Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timetable comparison #54

Open
LECUYER-David opened this issue Aug 15, 2024 · 0 comments
Open

timetable comparison #54

LECUYER-David opened this issue Aug 15, 2024 · 0 comments

Comments

@LECUYER-David
Copy link

LECUYER-David commented Aug 15, 2024

Hello everyone,

thanks for the clock-timepicker, it's great, it works perfectly

in my nature project, I have to compare times.
-early morning
-late morning
-early afternoon
-late afternoon.

for example it is impossible to have a schedule for the end of the morning before the start of the morning

I programmed it in javascript, if it helps anyone that's great

in the js, I will check that it is the correct time format 00:00 (etape=3).
Then after compare the order of the times if it is ok etape=4, otherwise text associated with the error.

example with attachment
L'horaire du matin doit être inférieur a celui du midi=>The morning schedule must be less than the midday schedule

Thank you for this project

Sincerely

david LECUYER

//start html

<input id="demijournee_deb_matin" class="time standard" type="text" value="06:00" >
<input id="demijournee_fin_matin" class="time standard" type="text" value="12:00" >
&nbsp;&nbsp;</td>
<input id="demijournee_deb_amidi" class="time standard" type="text" value="13:00" >
<input id="demijournee_fin_amidi" class="time standard" type="text" value="18:00" >

<span id="bp_envoyer_li" >$svg_envoyer</span>
	
	
<span id="bp_secu_text_en" style="font-style:italic;font-weight:bold;font-size:20px;color:red;" ></span>

//end html

//start javascript
if (document.getElementById("bp_envoyer_li")){
document.getElementById("bp_envoyer_li").addEventListener("click",function() {bp_envoyer_li();});
}

function bp_envoyer_li(){
etape=3;
if (etape==3){
//format attendu 08:00,20:00
horaires="";

		if (document.getElementById("demijournee_deb_matin").value!=""){			
				if (document.getElementById("demijournee_fin_matin").value!=""){
					if (document.getElementById("demijournee_deb_amidi").value!=""){
						if (document.getElementById("demijournee_fin_amidi").value!=""){
				
				horaires=document.getElementById("demijournee_deb_matin").value+','+document.getElementById("demijournee_fin_matin").value;
				horaires+=','+document.getElementById("demijournee_deb_amidi").value+','+document.getElementById("demijournee_fin_amidi").value;
						}
					}
				}
			}
	
if (horaires!=""){
	etape=3.5;
}else{
	document.getElementById("bp_secu_text_en").innerHTML='il faut remplir les horaires';
}	

}
if (etape==3.5){
var deb_matin=document.getElementById("demijournee_deb_matin").value;
var tab_deb_matin=deb_matin.split(':');
var deb_matin_seconde=parseInt(tab_deb_matin[0])*3600+parseInt(tab_deb_matin[1])*60;

		var fin_matin=document.getElementById("demijournee_fin_matin").value;
		var tab_fin_matin=fin_matin.split(':');
		var fin_matin_seconde=parseInt(tab_fin_matin[0])*3600+parseInt(tab_fin_matin[1])*60;
	
		var deb_amidi=document.getElementById("demijournee_deb_amidi").value;
		var tab_deb_amidi=deb_amidi.split(':');
		var deb_amidi_seconde=parseInt(tab_deb_amidi[0])*3600+parseInt(tab_deb_amidi[1])*60;
		
		var fin_amidi=document.getElementById("demijournee_fin_amidi").value;
		var tab_fin_amidi=fin_amidi.split(':');
		var fin_amidi_seconde=parseInt(tab_fin_amidi[0])*3600+parseInt(tab_fin_amidi[1])*60;
		
		if (deb_matin_seconde>fin_matin_seconde){
document.getElementById("bp_secu_text_en").innerHTML="L\'horaire du matin doit être inférieur a celui du midi";
		}else{
		if (fin_matin_seconde>deb_amidi_seconde){
document.getElementById("bp_secu_text_en").innerHTML="L\'horaire du midi doit être inférieur a celui du début d\'après-midi";
			}else{
		if (deb_amidi_seconde>fin_amidi_seconde){
document.getElementById("bp_secu_text_en").innerHTML="L\'horaire du début d\'après-midi doit être inférieur a celui du soir";	
				}else{
					etape=4;						
				}
			}
		}			

}
if (etape==4){
document.forms["horaires"].submit();
}
//end javascript
horaires

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant