Biomodèles/Biomodels
SCILAB 3.0 PAS A PAS
SCILAB 3.0 STEP-TO-STEP

Jacques-Deric Rouault

Laboratoire de Neurobiologie de l'Apprentissage, de la Mémoire et de la Communication. CNRS UMR 8620, Bat. 446, Université Paris-Sud, F91400 Orsay

Orscilab
ORSCILAB

11 LA MESURE DU TEMPS
11 MEASURING TIME
11.2 Le calendrier / The calendar
Version 2.1.5 du 26 janvier 2005 / Version 2.1.5, January 26th 2005
Biomodèles/Biomodels N°1 pp 0x-0y Décembre 2004 December 2004

Retour à la Table générale / Return to the General table
Index général / General index
Passage à la section suivante 11.3 / Next section 11.3

a
Affichage (Date, heure)
date
Display (Date, Hour)

b
getdate
s (getdate)

c
etime

La fonction date retourne la date sous forme d'une chaine de caracteres jj-mmm-aaaa
The function date returns the date under the form of a string dd-mmm-yyyy

// PROGRAMME SPAS110201 - date
s = date () ,

Ch11Sc02-Fig01

La fonction getdate retourne la date sous forme d'une vecteur à 10 champs entiers :
The function getdate returns the date under the form of a vector with 10 integer fields

Le champ 1 contient l'année à 4 chiffres.
The first field contains the year (4 digits).

Le champ 2 contient le mois entre 01 et 12.
The second field contains the month betxeen 01 and 12.

Le champ 3 contient la semaine entre 01 et 53.
The third field contains the week berween 01 and 53.

Le champ 4 contient le jour de l'année entre 000 et 366.
The fourth field contains the day of the year between 000 and 366.

Le champ 5 contient le jour de la semaine entre 1 (= dimanche) et 7 (=samedi).
The fifth fiels contains the day of then week between 1 (= sunday) and 7 (=saturday).

Le champ 6 contient le jour du mois entre 01 et 31.
The sixth field contains the day of the month between 01 and 31.

Le champ 7 contient l'heure du jour entre 00 et 23.
The seventh field contains the hour of the day between 00 and 23.

Le champ 8 contient la minute de l'heure entre 00 et 59.
The eighth field contains the minut of the hour between 00 and 59.

Le champ 9 contient la seconde de la minute entre 00 et 59.
The ninth field contains the second in the minit between 00 and 59.

Le champ 10 contient les millièmes de seconde.
The tenth field contains the tousandths of second.

// PROGRAMME SPAS110202 - getdate 1
v = getdate () ;
printf ("\nannée / year              = %d\n" ,v(1)) ;
printf ("mois / month              = %d\n" ,v(2)) ;
printf ("semaine / week            = %d\n" ,v(3)) ;
printf ("jour (année)/day (year)   = %d\n" ,v(4)) ;
printf ("jour (semaine)/day (week) = %d\n" ,v(5)) ;
printf ("jour (mois)/day (month)   = %d\n" ,v(6)) ;
printf ("heure / hour              = %d\n" ,v(7)) ;
printf ("minute / minit            = %d\n" ,v(8)) ;
printf ("seconde / second          = %d\n" ,v(9)) ;
printf ("millièmes / thousandths   = %d\n" ,v(10)) ;


Ch11Sc02-Fig02

La fonction getdate("s") retourne la date sous forme d'un flottant qui représente le nombre de secondes écoulées depuis le 1er janvier 1970.
The function getdate("s") returns the date under the form of a float, which is the number of seconds past since the 1er january 1970.

// PROGRAMME SPAS110203 - getdate 2
v = getdate ("s");
printf ("secondes / seconds  = %12d\n" ,v) ;

Ch11sc02-Fig03

La fonction getdate(x) retourne sous forme d'un vecteur à 9 champs la date qui correspond au nombre x de secondes écoulées depuis le 1er janvier 1970.
The function getdate(x)
returns the number x of seconds past since the 1er january 1970 under the form of a vector with 9 integer fields

// PROGRAMME SPAS110204 - getdate 3
x = getdate ("s");
v = getdate (x) ;
printf ("\nannée / year              = %d\n" ,v(1)) ;
printf ("mois / month              = %d\n" ,v(2)) ;
printf ("semaine / week            = %d\n" ,v(3)) ;
printf ("jour (année)/day (year)   = %d\n" ,v(4)) ;
printf ("jour (semaine)/day (week) = %d\n" ,v(5)) ;
printf ("jour (mois)/day (month)   = %d\n" ,v(6)) ;
printf ("heure / hour              = %d\n" ,v(7)) ;
printf ("minute / minit            = %d\n" ,v(8)) ;
printf ("seconde / second          = %d\n" ,v(9)) ;


Ch11Sc02-Fig04

Pour calculer le délai en secondes entre deux opérations, on effectue la différence entre deux appels successifs à la fonction getdate("s") (ajuster le numbre de zéros selon la rapidité de votre ordinateur).
To compute in seconds the time past between two operations, we make the differences between two successive calls to the function getdate("s") (adjust the number of zeros following the speed of your computer).

// PROGRAMME SPAS110205 - delai en secondes/delay in seconds
t1 = getdate ("s") ;
for i=1 : 1000000
  x = x+1 ;
end ;
t2 = getdate (
"s") ;
delai = t2-t1 ,


Ch11Sc02-Fig05

La fonction etime calcule en secondes le temps écoulé entre deux dates de format vectoriel à 6 ou 10 items.
The function etime comutes in seconds the time past between two dates in vectorial format with 6 or 10 items.

Le format vectoriel à 10 items est celui retourné par la fonction getdate.
The 10 items vectorial format is the one returned by the function getdate.

// PROGRAMME SPAS110206 - etime 1
v1 = getdate () ;
for i=1 : 1000000
  x = x+1 ;
end ;
v2 = getdate ();
delai = etime(v2,v1),

Ch11Sc02-Fig06

Le format vectoriel à 6 items comprend l'année, le mois, le jour, l'heure, la minute et la seconde (nombre décimal avec le nombre de millisecondes).

The 6 items vectorial format contains the year, the month, the day, the year, the minit and the second (decimal number with the number of milliseconds).


Retour à la Table générale / Return to the General table
Index général / General index
Passage à la section suivante 11.3 / Next section 11.3