From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ffe8077058c9c24b X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: Conversion to UNIX time Date: 2000/07/19 Message-ID: #1/1 X-Deja-AN: 648345006 References: <20000719014423.05992.00000168@ng-fz1.aol.com> Content-Type: text/plain; charset=us-ascii X-Complaints-To: dscoggin@cne-odin.gsfc.nasa.gov X-Trace: skates.gsfc.nasa.gov 964038156 29940 128.183.220.71 (19 Jul 2000 20:22:36 GMT) Organization: NASA Goddard Space Flight Center Mime-Version: 1.0 User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.5 NNTP-Posting-Date: 19 Jul 2000 20:22:36 GMT Newsgroups: comp.lang.ada Date: 2000-07-19T20:22:36+00:00 List-Id: tennisbb@aol.com (Tennisbb) writes: > My project has decided to name recording files (of which there will probably be > MANY) by a number of fields, the first two of which will be Start Time and End > Time in 8-digit Hex UNIX time. Despite our wide use of re-use, I can't locate > any routines to convert Calendar Time to an 8-digit Hex string, and wondered if > anyone has any procedures they'd be willing to share... The reason for the Hex > times is to reduce the search time later. Below is code to produce hex strings from unsigned integers. If you can convert time to an unsigned integer, you're all set. -- -- Stephe -- Abstract: -- -- Generic plain Hexadecimal image -- generic Width : Natural; type Number_Type is mod <>; function Sal.Generic_Hex_Image (Item : in Number_Type) return String; -- Return a hexadecimal image of Item, padded with leading zeros to Width. -- If Width is too small for Item, leading digits are silently truncated. -- Abstract: -- -- see spec -- function Sal.Generic_Hex_Image (Item : in Number_Type) return String is Temp : Number_Type := Item; Nibble : Number_Type; Image : String (1 .. Width); begin for I in reverse Image'Range loop Nibble := Temp mod 16; Temp := Temp / 16; if Nibble > 9 then Image (I) := Character'Val (Character'Pos ('A') + Nibble - 10); else Image (I) := Character'Val (Character'Pos ('0') + Nibble); end if; end loop; return Image; end Sal.Generic_Hex_Image;