From: Laurent <lutgenl@icloud.com>
Subject: Is there an easier way for this?
Date: Sun, 21 Jun 2015 11:38:34 -0700 (PDT)
Date: 2015-06-21T11:38:34-07:00 [thread overview]
Message-ID: <9894cde7-2cf8-4060-be65-857812ad7b09@googlegroups.com> (raw)
Hi
I need a function which generates some specific file names:
VITEK2-BCI_yymmdd_hhmmss_x.txt
where yymmdd is the current date, hhmmss the current time and x the number of txt files. No idea if x
actually important.
I have tinkered this together but I find it quite horrible. Is there a more elegant way to do it?
function Make_File_Name (How_Many : in Positive) return V_String.Bounded_String is
use V_String;
File_Name : V_String.Bounded_String:= (+"VITEK2-BCI_");
Temp : V_String.Bounded_String;
Right_Now : Ada.Calendar.Time := Ada.Calendar.Clock;
Y : Positive := Ada.Calendar.Year (Right_Now) rem 100;
M : Positive := Ada.Calendar.Month (Right_Now);
D : Positive := Ada.Calendar.Day (Right_Now);
Secs_Past_Midnight : Natural;
Mins_Past_Midnight : Natural;
Secs : Natural;
Mins : Natural;
Hrs : Natural;
begin
Secs_Past_Midnight := Natural (Ada.Calendar.Seconds (Right_Now));
Mins_Past_Midnight := Secs_Past_Midnight / 60;
Secs := Secs_Past_Midnight rem 60;
Mins := Mins_Past_Midnight rem 60;
Hrs := Mins_Past_Midnight / 60;
if Y < 10 then
Temp := (+"0" & Trim(Y'Img));
File_Name := File_Name & Temp;
else
Temp := Trim (Y'Img);
File_Name := File_Name & Temp;
end if;
if M < 10 then
Temp := (+"0" & Trim(M'Img));
File_Name := File_Name & Temp;
else
Temp := Trim (M'Img);
File_Name := File_Name & Temp;
end if;
if D < 10 then
Temp := (+"0" & Trim(D'Img));
File_Name := File_Name & Temp;
else
Temp := Trim (D'Img);
File_Name := File_Name & Temp;
end if;
File_Name := File_Name & "_";
if Hrs < 10 then
Temp := (+"0" & Trim(Hrs'Img));
File_Name := File_Name & Temp;
else
Temp := Trim (Hrs'Img);
File_Name := File_Name & Temp;
end if;
if Mins < 10 then
Temp := (+"0" & Trim(Mins'Img));
File_Name := File_Name & Temp;
else
Temp := Trim (Mins'Img);
File_Name := File_Name & Temp;
end if;
if Secs < 10 then
Temp := (+"0" & Trim(Secs'Img));
File_Name := File_Name & Temp;
else
Temp := Trim (Secs'Img);
File_Name := File_Name & Temp;
end if;
File_Name := File_Name & "_";
File_Name := File_Name & Trim (How_Many'Img) & ".txt";
return File_Name;
end Make_File_Name;
Thanks
Laurent
next reply other threads:[~2015-06-21 18:38 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-21 18:38 Laurent [this message]
2015-06-21 19:15 ` Is there an easier way for this? Niklas Holsti
2015-06-21 19:41 ` Laurent
2015-06-21 19:25 ` Jeffrey R. Carter
2015-06-21 19:42 ` Laurent
2015-06-22 12:23 ` Laurent
2015-06-22 15:01 ` G.B.
2015-06-22 15:40 ` Laurent
2015-06-22 16:47 ` Jeffrey R. Carter
2015-06-22 16:41 ` Laurent
2015-06-22 16:47 ` Jeffrey R. Carter
2015-06-22 17:18 ` Laurent
2015-06-22 18:04 ` What do you think about this? Laurent
2015-06-23 14:21 ` Stephen Leake
2015-06-23 19:51 ` Laurent
2015-06-23 20:20 ` Anh Vo
2015-06-23 21:03 ` Laurent
2015-06-23 22:17 ` Shark8
2015-06-24 5:57 ` Anh Vo
2015-06-24 7:58 ` Laurent
2015-06-24 21:06 ` Laurent
2015-06-24 21:45 ` Anh Vo
2015-06-24 21:59 ` Laurent
2015-06-24 22:35 ` Simon Wright
2015-06-24 22:59 ` Laurent
2015-06-25 2:56 ` Anh Vo
2015-06-25 7:29 ` Simon Wright
2015-06-25 16:55 ` Anh Vo
2015-06-25 17:27 ` Simon Wright
2015-06-25 18:13 ` Laurent
2015-06-25 18:36 ` Simon Wright
2015-06-24 23:10 ` Anh Vo
2015-06-24 10:17 ` Stephen Leake
2015-06-24 17:20 ` Jeffrey R. Carter
2015-06-24 20:50 ` Laurent
2015-06-24 22:30 ` Jeffrey R. Carter
2015-06-24 22:52 ` Laurent
2015-06-27 17:12 ` Laurent
2015-06-27 17:43 ` Jeffrey R. Carter
2015-06-27 17:47 ` J-P. Rosen
2015-06-27 18:54 ` Simon Wright
2015-06-27 19:37 ` Laurent
2015-06-27 19:47 ` Jeffrey R. Carter
2015-06-27 20:39 ` Simon Wright
2015-06-28 4:45 ` J-P. Rosen
2015-06-28 14:08 ` Stephen Leake
2015-06-28 16:10 ` Laurent
2015-06-25 13:16 ` Stephen Leake
2015-06-25 17:20 ` Jeffrey R. Carter
2015-07-02 21:51 ` Randy Brukardt
2015-07-03 12:31 ` Stephen Leake
2015-07-03 17:11 ` Laurent
2015-07-03 17:46 ` Jeffrey R. Carter
2015-07-03 18:49 ` Laurent
2015-07-04 3:26 ` Randy Brukardt
2015-07-03 19:17 ` Simon Wright
2015-07-04 3:30 ` Randy Brukardt
2015-07-04 4:19 ` Laurent
2015-07-04 7:43 ` Simon Wright
2015-07-04 9:07 ` Laurent
2015-07-04 7:42 ` Simon Wright
2015-07-05 0:56 ` Randy Brukardt
2015-07-03 17:35 ` Randy Brukardt
2015-07-05 13:55 ` Stephen Leake
2015-07-06 20:07 ` Randy Brukardt
2015-06-24 20:21 ` Laurent
2015-06-21 19:38 ` Is there an easier way for this? Pascal Obry
2015-06-21 19:54 ` Laurent
2015-06-21 20:39 ` Pascal Obry
2015-06-24 7:14 ` gautier_niouzes
2015-06-24 21:08 ` Laurent
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox