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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,34e6505a3616fb21,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-16 13:37:49 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!195.25.12.36!oleane.net!oleane!isdnet!enst!enst.fr!not-for-mail From: "Hans-Olof Danielsson" Newsgroups: comp.lang.ada Subject: Re: calander package - Proposal for dates Date: Fri, 16 Mar 2001 10:31:20 +0100 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: <200103160849.JAA00680@bulgaria.otn.eurocopter.de> Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 984762983 68311 137.194.161.2 (16 Mar 2001 17:16:23 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Fri, 16 Mar 2001 17:16:23 +0000 (UTC) To: Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: supernews.google.com comp.lang.ada:5759 Date: 2001-03-16T10:31:20+01:00 I think there is an ISO standard for date and time format with one of the formats being something like this: 2001-03-16 10:25:29 If there is such a standard format, it should be coverd by the package. HOD ----- Original Message ----- From: "Christoph Grein" To: Sent: Friday, March 16, 2001 9:49 AM Subject: Re: calander package - Proposal for dates > I've created a set of packages with specification. There's also > an implementation with test program. > It's not perfect (it's only for dates, not for times, and the Is_Leap_Year > function is maybe misplaced) but it might serve as a start. > I use two child packages, because otherwise the functions are not resolvable > when defaults are used. > (The mailer might ruin the indentation.) > ------------------------------------------------------------------------ > with Ada.Calendar; > with Ada.Strings.Unbounded; > use Ada.Strings.Unbounded; > > package Calendar_Format is > > --==================================================================== > -- Author Christoph Grein > -- Version 0.0 > -- Date 15 March 2001 > --==================================================================== > -- Various date formats are defined. > -- > -- Numeric formats consists of all numbers for days, months, and > -- years. > -- Text formats use names for months. To allow for language specific > -- names, they are defined with a (non-constant) array of (unbounded) > -- strings. > -- > -- Numeric Formats: > -- ---------------- > -- > -- These formats are described by enumeration literals where D stands > -- for a day digit, M for a month digit, and Y for a year digit. > -- A single character D or M signifies that only as much digits will > -- be used as needed, DD or MM signifies that always two digits will > -- be used. > -- YYYY signifies that all four digits of a year will be used, YY > -- signifies the abbreviate form. > -- > -- Examples: > -- > -- 10-12-1815 Lady Ada's birthday with > -- DD_MM_YYYY and '-' separator > -- 12/10/80 First Ada Standard DOD-MIL-STD 1815 with > -- MM_DD_YY and '/' separator > -- 1.1.2001 The begin of the new millenium with > -- D_M_YYYY or M_D_YYYY and '.' separator > -- 01.01.01 The same date with with DD_MM_YY or MM_DD_YY > -- > -- Text Formats: > -- ------------- > -- > -- There are tow formats differing only in the placement of day and > -- month. In day, month, year sequence, the values are separated by > -- one blank character, in month, day, year sequence, an additional > -- comma is inserted between day and year value. The day value uses > -- one or two digits as appropriate. > -- Additionally an ordinal separator may be inserted after the day > -- value. > -- > -- Examples: > -- > -- 10 December 1815 Day_Month_Year with None separator > -- 10. December 1980 Day_Month_Year with '.' separator > -- December 10, 1980 Month_Day_Year with None separator > -- December 10th, 1980 Month_Day_Year with English_Ordinal separator > -- 1st January 2001 Day_Month_Year with English_Ordinal separator > --==================================================================== > -- History > -- Author Version Date Reason for change > -- C.G. 0.0 15.03.2001 PDL > --==================================================================== > > use Ada; > > function Is_Leap_Year (Year: Calendar.Year_Number) return Boolean; > > -- Numeric Formats: > > type Numeric_Date_Format is (D_M_YY, > D_M_YYYY, > DD_MM_YY, > DD_MM_YYYY, > MM_DD_YY, > MM_DD_YYYY, > YYYY_MM_DD); > > Standard_Numeric_Date_Format: Numeric_Date_Format := D_M_YYYY; > > type Numeric_Date_Separator is ('-', '.', '/'); > > Standard_Numeric_Separator: Numeric_Date_Separator := '.'; > > -- Text Formats: > > type Text_Date_Format is (Day_Month_Year, > Month_Day_Year); > > Standard_Text_Date_Format: Text_Date_Format := Day_Month_Year; > > type Text_Date_Separator is (None, English_Ordinal, '.'); > > Standard_Text_Date_Separator: Text_Date_Separator := '.'; > > type Month_Names is array (Calendar.Month_Number) of Unbounded_String; > > Standard_Names: Month_Names := (To_Unbounded_String ("January"), > To_Unbounded_String ("February"), > To_Unbounded_String ("March"), > To_Unbounded_String ("April"), > To_Unbounded_String ("May"), > To_Unbounded_String ("June"), > To_Unbounded_String ("July"), > To_Unbounded_String ("August"), > To_Unbounded_String ("September"), > To_Unbounded_String ("October"), > To_Unbounded_String ("November"), > To_Unbounded_String ("December")); > > end Calendar_Format; > ------------------------------------------------------------------------ > package Calendar_Format.Numeric is > > --==================================================================== > -- Author Christoph Grein > -- Version 0.0 > -- Date 15 March 2001 > --==================================================================== > -- Calculate the date image in the requested format. > -- > -- There are two overloaded functions: One takes a Calendar.Time as > -- input, the other a year, month and day number. > --==================================================================== > -- History > -- Author Version Date Reason for change > -- C.G. 0.0 15.03.2001 PDL > --==================================================================== > > function Date_Image (Date : Calendar.Time; > Format : Numeric_Date_Format := > Standard_Numeric_Date_Format; > Separator: Numeric_Date_Separator := > Standard_Numeric_Separator) return String; > function Date_Image (Year : Calendar.Year_Number; > Month : Calendar.Month_Number; > Day : Calendar.Day_Number; > Format : Numeric_Date_Format := > Standard_Numeric_Date_Format; > Separator: Numeric_Date_Separator := > Standard_Numeric_Separator) return String; > > end Calendar_Format.Numeric; > ------------------------------------------------------------------------ > package Calendar_Format.Text is > > --==================================================================== > -- Author Christoph Grein > -- Version 0.0 > -- Date 15 March 2001 > --==================================================================== > -- Calculate the date image in the requested format. > -- > -- There are two overloaded functions: One takes a Calendar.Time as > -- input, the other a year, month and day number. > --==================================================================== > -- History > -- Author Version Date Reason for change > -- C.G. 0.0 15.03.2001 PDL > --==================================================================== > > function Date_Image (Date : Calendar.Time; > Format : Text_Date_Format := > Standard_Text_Date_Format; > Separator: Text_Date_Separator := > Standard_Text_Date_Separator; > Names : Month_Names := Standard_Names) return > String; > function Date_Image (Year : Calendar.Year_Number; > Month : Calendar.Month_Number; > Day : Calendar.Day_Number; > Format : Text_Date_Format := > Standard_Text_Date_Format; > Separator: Text_Date_Separator := > Standard_Text_Date_Separator; > Names : Month_Names := Standard_Names) return > String; > > end Calendar_Format.Text; > > > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada