Skip to content

Commit

Permalink
A agpl-calendar-serializable_time.adb
Browse files Browse the repository at this point in the history
A    agpl-calendar-serializable_time.ads
  • Loading branch information
mosteo committed Jun 29, 2006
1 parent bae81cc commit 908a7d7
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
29 changes: 29 additions & 0 deletions agpl-calendar-serializable_time.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package body Agpl.Calendar.Serializable_Time is

----------
-- 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;
62 changes: 62 additions & 0 deletions agpl-calendar-serializable_time.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
------------------------------------------------------------------------------
-- ADAGIO - ADALID - AENEA. --
-- --
-- Copyright (C) 2003 --
-- A. Mosteo. --
-- --
-- Authors: A. Mosteo. (adagio@mosteo.com) --
-- --
-- If you have any questions in regard to this software, please address --
-- them to the above email. --
-- --
-- This program is free software; you can redistribute it and/or modify --
-- it under the terms of the GNU General Public License as published by --
-- the Free Software Foundation; either version 2 of the License, or (at --
-- your option) any later version. --
-- --
-- This program is distributed in the hope that it will be useful, but --
-- WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public License --
-- along with this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- You are not allowed to use any part of this code to develop a program --
-- whose output would be used to harass or prosecute other users of the --
-- networks Adagio connects with. All data collected with Adagio or a tool --
-- containing Adagio code about other network users must remain --
-- confidential and cannot be made public by any mean, nor be used to --
-- harass or legally prosecute these users. --
------------------------------------------------------------------------------
-- $Id: agpl-calendar.ads,v 1.1 2004/01/21 21:05:52 Jano Exp $

with Ada.Calendar;
with Ada.Streams;

-- A Time can't be streamed to remote machines. This is an extension of
-- regular timestamps that replaces 'Read and 'Write with proper
-- serialization subprograms.

package Agpl.Calendar.Serializable_Time is

-- pragma Elaborate_Body;

type Object is new Ada.Calendar.Time;

procedure Read (Stream : access Ada.Streams.Root_Stream_Type'Class;
This : out Object);
for Object'Read use Read;

procedure Write (Stream : access Ada.Streams.Root_Stream_Type'Class;
This : in Object);
for Object'Write use Write;

private

use Ada.Calendar;

Epoch : constant Object := Time_Of (1970, 1, 1, 0.0);

end Agpl.Calendar.Serializable_Time;

0 comments on commit 908a7d7

Please sign in to comment.