From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: =?UTF-8?Q?Bj=c3=b6rn_Lundin?= Newsgroups: comp.lang.ada Subject: Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? Date: Sun, 24 Oct 2021 14:09:30 +0200 Organization: A noiseless patient Spider Message-ID: References: <5dcbccb3-1e2b-42cb-91e1-4be31442a647n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 24 Oct 2021 12:09:31 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="f6cedc6941dbf2fd9cfb18f3afeccc43"; logging-data="16942"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+hsN9S1NrfrukV14jpWot+" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 Cancel-Lock: sha1:TN3R8aU0pmo5JXg2ck8benpAq2c= In-Reply-To: <5dcbccb3-1e2b-42cb-91e1-4be31442a647n@googlegroups.com> Content-Language: sv Xref: reader02.eternal-september.org comp.lang.ada:63075 List-Id: Den 2021-10-24 kl. 08:52, skrev reinert: > Ada seems to guarantee that Duration covers 24 hours (?). What you do when you need to represent for example 5 years? we use a types of our own at work subtype Year_Type is Integer_2 range 1901 .. 2099; subtype Month_Type is Integer_2 range 01 .. 12; subtype Day_Type is Integer_2 range 01 .. 31; subtype Hour_Type is Integer_2 range 00 .. 23; subtype Minute_Type is Integer_2 range 00 .. 59; subtype Second_Type is Integer_2 range 00 .. 59; subtype Millisecond_Type is Integer_2 range 000 .. 999; subtype Week_Type is Integer_2 range 1 .. 53; subtype Year_Day_Type is Integer_2 range 1 .. 366; type Week_Day_Type is ( Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday); subtype Interval_Day_Type is Integer_4 range 0 .. Integer_4'Last; subtype Seconds_Type is Integer_4 range 0 .. Integer_4'Last; type Time_Type is tagged record Year : Year_Type; Month : Month_Type; Day : Day_Type; Hour : Hour_Type; Minute : Minute_Type; Second : Second_Type; Millisecond : Millisecond_Type; end record; and type Interval_Type is tagged record Days : Interval_Day_Type; Hours : Hour_Type; Minutes : Minute_Type; Seconds : Second_Type; Milliseconds : Millisecond_Type; end record; with functions and conversion to handle "+" "-" and some more ( Time - Time results in duration) we have a limited need of dates from the past and into the future, and ms is usually enough granularity. (This was designed in the late 80:ies but still usefull) This is to cover the needs of our administrative system >> The user interface is responsible to convert anything to Duration and back. >> >> -- >> Regards, >> Dmitry A. Kazakov >> http://www.dmitry-kazakov.de and Dmitry is right in saying the user interface should convert to the units the user likes -- Björn