Accueil > > > CALCULER LE NOMBRE D'HEURES DE NUITS D'UN CRÉNEAU HORAIRE
CALCULER LE NOMBRE D'HEURES DE NUITS D'UN CRÉNEAU HORAIRE
Information sur la source
Description
Bonjour à tous Les fonctions temvern et nvertem sont les mêmes que dans l'une des contrib que j'avais postée qui s'appelle dift http://www.atoutfox.org/articles.asp?ACTION=FCON SULTER&ID=0000000066 Ici il s'agit de calculer le nombre d'heures de nuits, en partant d'une heure de début et une heure de fin Heuredeb et heurfin sont en caractère "HH:MM:SS" ex toto=heuresnut("10:00:00","23:00:00","22:00","07:0 0") retournera "01:00:00" A Améliorer : Des tests en entrée de fonction, afin de s'assurer que les paramètres sont bien en texte Bonne journée à tous Eric
Source
- function heuresnuit
- parameters hdeb,hfin,debnuit,finnuit
- **
- ** toto= heuresnuit(heurdeb, heurfin,"22:00","07:00")
- local retour,minuitdeb,minuitfin,hdeb,hfin;debnuit,finhuit,hfin31,retour
- minuitdeb=temvern("00:00")
- minuitfin=temvern("24:00")
- hdeb=temvern(left(hdeb,5))
- hfin=temvern(left(hfin,5))
- debnuit=temvern(debnuit)
- finnuit=temvern(finnuit)
- hfin31= minuitfin+finnuit
- retour=nvertem(0)
- do case
- case between(hdeb,debnuit,minuitfin) .and. between(hfin,debnuit,minuitfin)
- retour=nvertem(hfin-hdeb)
- case between(hdeb,minuitdeb,finnuit) .and. between(hfin,minuitdeb,finnuit)
- retour=nvertem(hfin-hdeb)
- case between(hdeb,debnuit,minuitfin) .and. between(hfin,minuitdeb,finnuit)
- retour=nvertem((minuitfin-hdeb)+hfin-minuitdeb)
- case between(hfin,debnuit,minuitfin) .and. hdeb <debnuit
- retour=nvertem(hfin-debnuit)
- case between(hfin,minuitdeb,finnuit) .and. hdeb <debnuit
- retour=nvertem(hfin-minuitdeb+ (minuitfin-debnuit))
- case hfin > finnuit .and. hfin<debnuit .and. between(hdeb,minuitdeb,finnuit)
- retour=nvertem(finnuit-hdeb)
- case hfin > finnuit .and. hfin<debnuit .and.between(hdeb,debnuit,minuitfin)
- retour=nvertem((finnuit-minuitdeb)+(minuitfin-hdeb))
- case hdeb<debnuit .and. hfin>finnuit .and. hfin<hdeb
- retour=nvertem((finnuit-minuitdeb)+(minuitfin-debnuit))
- case between(hfin,minuitfin,hfin31) .and. between(hdeb,debnuit,minuitfin)
- retour = nvertem(hfin-minuitfin +(minuitfin-hdeb))
- case between(hfin,minuitfin,hfin31).and. hdeb< debnuit .and. hdeb > finnuit
- retour = nvertem(hfin-minuitfin +(minuitfin-debnuit))
- case between(hfin,minuitfin,hfin31).and. hdeb< debnuit .and. hdeb <= finnuit
- retour = nvertem(hfin-minuitfin -(hdeb-minuitdeb))
-
-
- *-
- case hfin > hfin31 .and. between(hdeb,debnuit,minuitfin)
- retour = nvertem(finnuit-minuitfin +(minuitfin-hdeb))
- case hfin > hfin31 .and. hdeb< debnuit
- retour = nvertem(minuitfin-debnuit +(minuitfin-debnuit))
-
-
-
-
- endcase
- return righ(retour,5)+":00"
-
-
-
-
- function temvern
- parameters temp1
- temp1=alltrim(temp1)
- local s,m,h
- s=substr(temp1,len(temp1)-1,2)
- s=val(s)
- m=substr(temp1,len(temp1)-4,2)
- m=val(m)*60
- h=substr(temp1,1,len(temp1)-6)
- h=val(h)*3600
- retour=h+m+s
- return retour
-
-
- function nvertem
- parameters temp1
- local s,m,h
- h=int(temp1/3600)
- resth=mod(temp1,3600)
-
- m=int((resth)/60)
- restm=mod(m,60)
-
- s=int(mod(resth,60))
-
-
- return padl(h,5,"0")+":"+padl(m,2,"0")+":"+padl(s,2,"0")
-
function heuresnuit
parameters hdeb,hfin,debnuit,finnuit
**
** toto= heuresnuit(heurdeb, heurfin,"22:00","07:00")
local retour,minuitdeb,minuitfin,hdeb,hfin;debnuit,finhuit,hfin31,retour
minuitdeb=temvern("00:00")
minuitfin=temvern("24:00")
hdeb=temvern(left(hdeb,5))
hfin=temvern(left(hfin,5))
debnuit=temvern(debnuit)
finnuit=temvern(finnuit)
hfin31= minuitfin+finnuit
retour=nvertem(0)
do case
case between(hdeb,debnuit,minuitfin) .and. between(hfin,debnuit,minuitfin)
retour=nvertem(hfin-hdeb)
case between(hdeb,minuitdeb,finnuit) .and. between(hfin,minuitdeb,finnuit)
retour=nvertem(hfin-hdeb)
case between(hdeb,debnuit,minuitfin) .and. between(hfin,minuitdeb,finnuit)
retour=nvertem((minuitfin-hdeb)+hfin-minuitdeb)
case between(hfin,debnuit,minuitfin) .and. hdeb <debnuit
retour=nvertem(hfin-debnuit)
case between(hfin,minuitdeb,finnuit) .and. hdeb <debnuit
retour=nvertem(hfin-minuitdeb+ (minuitfin-debnuit))
case hfin > finnuit .and. hfin<debnuit .and. between(hdeb,minuitdeb,finnuit)
retour=nvertem(finnuit-hdeb)
case hfin > finnuit .and. hfin<debnuit .and.between(hdeb,debnuit,minuitfin)
retour=nvertem((finnuit-minuitdeb)+(minuitfin-hdeb))
case hdeb<debnuit .and. hfin>finnuit .and. hfin<hdeb
retour=nvertem((finnuit-minuitdeb)+(minuitfin-debnuit))
case between(hfin,minuitfin,hfin31) .and. between(hdeb,debnuit,minuitfin)
retour = nvertem(hfin-minuitfin +(minuitfin-hdeb))
case between(hfin,minuitfin,hfin31).and. hdeb< debnuit .and. hdeb > finnuit
retour = nvertem(hfin-minuitfin +(minuitfin-debnuit))
case between(hfin,minuitfin,hfin31).and. hdeb< debnuit .and. hdeb <= finnuit
retour = nvertem(hfin-minuitfin -(hdeb-minuitdeb))
*-
case hfin > hfin31 .and. between(hdeb,debnuit,minuitfin)
retour = nvertem(finnuit-minuitfin +(minuitfin-hdeb))
case hfin > hfin31 .and. hdeb< debnuit
retour = nvertem(minuitfin-debnuit +(minuitfin-debnuit))
endcase
return righ(retour,5)+":00"
function temvern
parameters temp1
temp1=alltrim(temp1)
local s,m,h
s=substr(temp1,len(temp1)-1,2)
s=val(s)
m=substr(temp1,len(temp1)-4,2)
m=val(m)*60
h=substr(temp1,1,len(temp1)-6)
h=val(h)*3600
retour=h+m+s
return retour
function nvertem
parameters temp1
local s,m,h
h=int(temp1/3600)
resth=mod(temp1,3600)
m=int((resth)/60)
restm=mod(m,60)
s=int(mod(resth,60))
return padl(h,5,"0")+":"+padl(m,2,"0")+":"+padl(s,2,"0")
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
horloge en foxpro [ par engelina33 ]
Bonsoir,y'a t'il quelqu'un qui peut m'indiquer un moyen pour afficher une horloge et donnez la main à l'utilisateur de sélectionné une heure et me ret
|
Derniers Blogs
[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko [FRAMEWORK 4] LES TASKS ET LE THREAD UI[FRAMEWORK 4] LES TASKS ET LE THREAD UI par fathi
Je viens de passer quelques temps au TechDay's et j'ai pu voir pas mal de session intéressante. Par contre une chose m'a un peu étonné lors de certaines de ces sessions qui abordaient les améliorations du framework .NET (donc le 4.5) : en gros, bea...
Cliquez pour lire la suite de l'article par fathi
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|