Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Fortran

Idiom #261 Format time hours-minutes-seconds

Assign to the string x the value of fields (hours, minutes, seconds) of the date d, in format HH:MM:SS.

integer, dimension(8) :: d
character (len=8) :: x
call date_and_time (values=d)
write (unit=x,fmt='(I2.2,":",I2.2,":",I2.2)') d(5), d(6), d(7)
with Ada.Calendar.Formatting;
X : constant String :=
    Ada.Calendar.Formatting.Image (D) (12 .. 19);

Image returns date as well therefore the slice

New implementation...
< >
programming-idioms.org