FUNCTION hms, cheure, TAB = ih
;+ ***********************************************************************
; NAME:
;	HMS
; PURPOSE:
;	   Cette fonction transforme une chaine de caractere exprimant un temps
;          en milliseconde (entier long) et en option en tableau (h,mn,sec,ms)
;          FORMAT D'ENTREE DE L'HEURE : HH:MM:SS:Millisecondes
;				   ou   HH:MM:SS.sss...
;                                  ou   HH ou HH:MM ou HH:MM:SS
; CATEGORY:
;	CONVERSION
; CALLING SEQUENCE:
;	ih = intarr(4)
;	ims = hms (cheure) ou ims = hms (cheure, TAB = ih)
; INPUTS:
;	heure en ASCII  format  : HH:MM:SS:Millisecondes
;			     ou   HH:MM:SS.sss...
; KEYWORD PARAMETERS:
;	TAB: l'heure est demandee aussi sous forme de tableau (h,mn,sec,ms)
;	     avant appel declarer un tableau ih=intarr(4)
; OUTPUTS:
;	Ims: heure en millisec      (LONG)
; EXAMPLE:
;	ihms = HMS('10:00:00.99')  ou ihms = HMS('10:00:00.777')
;	ou ih = intarr(4) & ihms = HMS('10:00:00.99',tab=ih)
; MODIFICATION HISTORY:
;	Ecrit par: A. Bouteille
;       peut convertir les 2 types de format avec '.' ou ':' comme
;	separateur des secondes et decimales de secondes,
;	La chaine fournie peut etre incomplete : HMS('10')  ou HMS('10:00')
;	L'option heure renvoyee en (h,m,s,ms) a ete ajoutee  
;-******************************************************************* 
   hh=str_sep(cheure,':')
   if n_elements(hh) eq 4 then begin
      pos= rstrpos(cheure,':')
      strput,cheure,'.',pos
      hh=str_sep(cheure,':')
   endif
  if n_elements(hh) eq 1 then hh=[hh,'00','00.000']
  if n_elements(hh) eq 2 then hh=[hh,'00.000']
; calcul de l'heure ih en h,m,s,ms
  ih=lonarr(4)
  ih(0:1)=long(hh(0:1))
  sec=float(hh(2))
  ih(2)=long(sec)
  ih(3)=round((sec-ih(2))*1000.)
  temp = [3600L * 1000L,  60L * 1000L, 1000L, 1L]
  return,(transpose(temp)#long(ih))(0)
  end
