agpl_1.0.0_b5da3320/src/agpl-calendar-serializable_time.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
31
32
33
34
35
36
37
38
39
40
41
42
43
package body Agpl.Calendar.Serializable_Time is

   ---------
   -- "+" --
   ---------

   function "+" (This : in Object) return Ada.Calendar.Time is
   begin
      return Ada.Calendar.Time (This);
   end "+";

   function "+" (This : in Ada.Calendar.Time) return Object is
   begin
      return Object (This);
   end "+";

   ----------
   -- Read --
   ----------

   procedure Read
     (Stream : access Ada.Streams.Root_Stream_Type'Class;
      This   :    out Object)
   is
      Elapsed : Duration;
   begin
      Duration'Read (Stream, Elapsed);
      This := Epoch + Elapsed;
   end Read;

   -----------
   -- Write --
   -----------

   procedure Write
     (Stream : access Ada.Streams.Root_Stream_Type'Class;
      This   : in     Object)
   is
   begin
      Duration'Write (Stream, This - Epoch);
   end Write;

end Agpl.Calendar.Serializable_Time;