begin process at 2010 09 04 13:04:59
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Prog. Objet

 > 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

Source avec Zip Source avec une capture ETAT DYNAMIQUE
UN AUTRE CALENDRIER
CALCUL DE CLE IBAN
FTP AVEC THERMOMETRE
CREER UNE TABLE CONTENANT LA LITES COMPLÈTE DES OBJETS CONTE...

 Sources de la même categorie

UN AUTRE CALENDRIER par aumeric
CALCUL DE CLE IBAN par aumeric
FONCTION DE CONVERSION DE CHIFFRES EN LETTRES par aumeric
RECHERCHE D'UNE VALEUR DE CLEF DANS LE REGISTRE par johnmary
Source avec Zip EXPÉDIER UN EMAIL : VFPWINSOCK / VFPSENDMAIL : EXPÉDITION DE... par FrancisFaure

 Sources en rapport avec celle ci

CALCUL DE CLE IBAN par aumeric
[VFP]CLASSE SYSTEMTIME par FredArmoni
Source avec Zip CALCUL D'UN EMPRUNT AVEC TAUX SIMPLE OU COMPOSE par johnmary
FONCTION DE CALCUL DE DIFFÉRENCE D'UNE HEURE À UNE AUTRE par aumeric
FONCTION DE CALCUL DE CLE RIB par aumeric

Commentaires et avis

Aucun commentaire pour le moment.

 Ajouter un commentaire


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


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Septembre 2010
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
27282930   

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,562 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales