1------------------------------------------------------------------------------ 2-- -- 3-- Matreshka Project -- 4-- -- 5-- Localization, Internationalization, Globalization for Ada -- 6-- -- 7-- Runtime Library Component -- 8-- -- 9------------------------------------------------------------------------------ 10-- -- 11-- Copyright © 2011-2013, Vadim Godunko <vgodunko@gmail.com> -- 12-- All rights reserved. -- 13-- -- 14-- Redistribution and use in source and binary forms, with or without -- 15-- modification, are permitted provided that the following conditions -- 16-- are met: -- 17-- -- 18-- * Redistributions of source code must retain the above copyright -- 19-- notice, this list of conditions and the following disclaimer. -- 20-- -- 21-- * Redistributions in binary form must reproduce the above copyright -- 22-- notice, this list of conditions and the following disclaimer in the -- 23-- documentation and/or other materials provided with the distribution. -- 24-- -- 25-- * Neither the name of the Vadim Godunko, IE nor the names of its -- 26-- contributors may be used to endorse or promote products derived from -- 27-- this software without specific prior written permission. -- 28-- -- 29-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- 30-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- 31-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- 32-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- 33-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- 34-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- 35-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- 36-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- 37-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- 38-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- 39-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- 40-- -- 41------------------------------------------------------------------------------ 42-- $Revision: 3654 $ $Date: 2013-01-19 13:11:21 +0400 (Sat, 19 Jan 2013) $ 43------------------------------------------------------------------------------ 44-- This package provides subprograms to extract julian day number and time 45-- inside day from X/Open representation and to construct X/Open 46-- representation from julian day number and time inside day. 47-- 48-- Subprograms in this package handles leap seconds also. 49-- 50-- Note: for convenience, julian day starts at midnight, not noon. 51------------------------------------------------------------------------------ 52 53package Matreshka.Internals.Calendars.Times is 54 55 pragma Preelaborate; 56 57 subtype Hour_Number is Integer range 0 .. 23; 58 subtype Minute_Number is Integer range 0 .. 59; 59 subtype Second_Number is Integer range 0 .. 60; 60 subtype Nano_Second_100_Number is Integer range 0 .. 9_999_999; 61 62 function Create 63 (Zone : not null Time_Zone_Access; 64 Julian_Day : Julian_Day_Number; 65 Hour : Hour_Number; 66 Minute : Minute_Number; 67 Second : Second_Number; 68 Nano_100 : Nano_Second_100_Number) return Absolute_Time; 69 -- Creates absolute time from giving components. 70 71 function Julian_Day 72 (Stamp : Absolute_Time; 73 Zone : not null Time_Zone_Access) return Julian_Day_Number; 74 -- Returns julian day number of the specified X/Open time. 75 76 function Hour 77 (Stamp : Absolute_Time; 78 Zone : not null Time_Zone_Access) return Hour_Number; 79 function Hour (Time : Relative_Time) return Hour_Number; 80 -- Returns the hour part (0 to 23) of the time. 81 82 function Minute 83 (Stamp : Absolute_Time; 84 Zone : not null Time_Zone_Access) return Minute_Number; 85 function Minute (Time : Relative_Time) return Minute_Number; 86 -- Returns the minute part (0 to 59) of the time. 87 88 function Second 89 (Stamp : Absolute_Time; 90 Zone : not null Time_Zone_Access) return Second_Number; 91 function Second 92 (Time : Relative_Time; Leap : Relative_Time) return Second_Number; 93 -- Returns the second part (0 to 60) of the time. 94 95 function Nanosecond_100 96 (Time : Relative_Time; Leap : Relative_Time) return Nano_Second_100_Number; 97 function Nanosecond_100 98 (Stamp : Absolute_Time; 99 Zone : not null Time_Zone_Access) return Nano_Second_100_Number; 100 -- Returns the second fraction part (0 to 9_999_999) of the time. 101 102 procedure Split 103 (Zone : not null Time_Zone_Access; 104 Stamp : Absolute_Time; 105 Julian_Day : out Julian_Day_Number; 106 Time : out Relative_Time; 107 Leap : out Relative_Time); 108 -- Splits stamp onto julian day number, relative time and leap second 109 -- fraction. 110 111 procedure Split 112 (Zone : not null Time_Zone_Access; 113 Stamp : Absolute_Time; 114 Julian_Day : out Julian_Day_Number; 115 Hour : out Hour_Number; 116 Minute : out Minute_Number; 117 Second : out Second_Number; 118 Nanosecond_100 : out Nano_Second_100_Number); 119 -- Splits stamp onto julian day number and splitted time inside day. Leap 120 -- second is returned as Second equal to 60. It is not necessary last 121 -- second of the day due to timezone correction. 122 123end Matreshka.Internals.Calendars.Times; 124