zipada_56.0.2_b3043499/extras/touch2.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
with Ada_Directories_Extensions;
with Ada.Calendar;
with Ada.Command_Line;
with Ada.Text_IO;

procedure Touch2 is

  use Ada_Directories_Extensions;
  use Ada.Calendar;
  use Ada.Command_Line;
  use Ada.Text_IO;

begin
  Set_Modification_Time (
    Argument (1),
    Time_Of (
      Year  => Integer'Value (Argument (2)),
      Month => Integer'Value (Argument (3)),
      Day   => Integer'Value (Argument (4)),
      Seconds => Duration (
        Integer'Value (Argument (5)) * 60 * 60 +
        Integer'Value (Argument (6)) *      60 +
        Integer'Value (Argument (7))
      )
    )
  );
exception
  when Constraint_Error =>
    Put_Line ("Syntax: touch2 file year month day hour minute second");
end;