[Scilab-users] Scilab date and hour functions

Serge Steer serge.steer at inria.fr
Wed Nov 28 23:31:34 CET 2012



----- Mail original -----
> De: "julien.langouet" <julien.langouet at gmail.com>
> À: users at lists.scilab.org
> Envoyé: Mercredi 28 Novembre 2012 20:16:17
> Objet: [Scilab-users] Scilab date and hour functions

> 
> My question is : How can I display or create a matrix with the time
> in a different format? I would like to have the time displayed in this
> kind of format hh:mm:ss,ms for exemple : 01:15:36,4 ...
> Is this possible?
> 
It depends on what you what to do: if your purpose is only display you can use the solution proposed by samuel into a dedicated  display function

for example, suppose you have a 3 column matrix X where the last one is time
you can write the function as follow:
function mydist(X)
  [A, M, J, h, mn, s] = datevec(X(:,3)/1000/24/3600);
  out = msprintf("%02d:%02d:%04.1f\n",h, mn ,s)
  mprintf("%.3g %.3g %s\",X(:,1),X(:,2),out)
endfunction

If you want to create an array with a string column formatted  as you want, you may use a tlist

[A, M, J, h, mn, s] = datevec(X(:,3)/1000/24/3600);
out = msprintf("%02d:%02d:%04.1f\n",h, mn ,s)
T=tlist(["foo","data","time"],X(:,1:2),out)

I hope it will help.

Serge Steer
> 
> --
> View this message in context:
> http://mailinglists.scilab.org/Scilab-date-and-hour-functions-tp4025363.html
> Sent from the Scilab users - Mailing Lists Archives mailing list
> archive at Nabble.com.
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
> 



More information about the users mailing list