1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . C A L E N D A R . A R I T H M E T I C --
9 -- Copyright (C) 2006-2009, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 package body Ada.Calendar.Arithmetic is
34 --------------------------
35 -- Implementation Notes --
36 --------------------------
38 -- All operations in this package are target and time representation
39 -- independent, thus only one source file is needed for multiple targets.
45 function "+" (Left : Time; Right : Day_Count) return Time is
46 R : constant Long_Integer := Long_Integer (Right);
48 return Arithmetic_Operations.Add (Left, R);
51 function "+" (Left : Day_Count; Right : Time) return Time is
52 L : constant Long_Integer := Long_Integer (Left);
54 return Arithmetic_Operations.Add (Right, L);
61 function "-" (Left : Time; Right : Day_Count) return Time is
62 R : constant Long_Integer := Long_Integer (Right);
64 return Arithmetic_Operations.Subtract (Left, R);
67 function "-" (Left, Right : Time) return Day_Count is
70 Leap_Seconds : Integer;
71 pragma Warnings (Off, Seconds); -- temporary ???
72 pragma Warnings (Off, Leap_Seconds); -- temporary ???
73 pragma Unreferenced (Seconds, Leap_Seconds);
75 Arithmetic_Operations.Difference
76 (Left, Right, Days, Seconds, Leap_Seconds);
77 return Day_Count (Days);
88 Seconds : out Duration;
89 Leap_Seconds : out Leap_Seconds_Count)
91 Op_Days : Long_Integer;
94 Arithmetic_Operations.Difference
95 (Left, Right, Op_Days, Seconds, Op_Leaps);
96 Days := Day_Count (Op_Days);
97 Leap_Seconds := Leap_Seconds_Count (Op_Leaps);
100 end Ada.Calendar.Arithmetic;