comp.lang.ada
 help / color / mirror / Atom feed
* Ada95 calendar package question
@ 2001-06-27  0:54 Vladimir Bednikov
  2001-06-27  3:44 ` James Rogers
                   ` (3 more replies)
  0 siblings, 4 replies; 34+ messages in thread
From: Vladimir Bednikov @ 2001-06-27  0:54 UTC (permalink / raw)


Hi all,

I'm using gnat3.13p on an sgi with gcc2.8.1 and am wondering if there is a
way of
getting the day of week and month in text format. I.E.
Mon, Tue, Wed, Thu, Fri, Sat and Sun for days of the week and
Jan, Feb, Mar, Apr .... for the month of the year.

Thanks in advance.





^ permalink raw reply	[flat|nested] 34+ messages in thread
[parent not found: <Pine.LNX.4.21.0106271731050.8027-100000@borba.ncc.up.pt>]
* RE: Ada95 calendar package question
@ 2001-06-27 20:39 Beard, Frank
  2001-06-27 21:25 ` Larry Hazel
  0 siblings, 1 reply; 34+ messages in thread
From: Beard, Frank @ 2001-06-27 20:39 UTC (permalink / raw)
  To: 'comp.lang.ada@ada.eu.org'


-----Original Message-----
From: James Rogers [mailto:jimmaureenrogers@worldnet.att.net]

> Converting month numbers to month names is simple. Create an enumerated
> type containing the month names you want, then convert the 
> Ada.Calendar.Month_Number to the corresponding month name:
>
> type months is (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep,
>                 Oct, Nov, Dec);
> Month_Name : Months := Months'Val(Ada.Calendar.Month(Time_Value));

Except that Ada.Calendar.Month returns a number in the range of 1 to 12,
while 'POS and 'VAL for type months works on values in the range of 0 to 11.

So, you would have to do something like the following:

  Month_Name : Months := Months'Val(Ada.Calendar.Month(Time_Value) - 1);

But that would probably cause CONSTRAINT_ERROR in January, so you end up
with:

  Month_Name : Months := Months'Val(natural(Ada.Calendar.Month(Time_Value))
- 1);

Frank



^ permalink raw reply	[flat|nested] 34+ messages in thread
* RE: Ada95 calendar package question
@ 2001-06-27 21:55 Beard, Frank
  0 siblings, 0 replies; 34+ messages in thread
From: Beard, Frank @ 2001-06-27 21:55 UTC (permalink / raw)
  To: 'comp.lang.ada@ada.eu.org'



-----Original Message-----
From: Larry Hazel [mailto:lhazel@mindspring.com]

> type Months is (Ignore, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct,
Nov,
> Dec);

Yes, but then you have put a comment above it explaining what "Ignore" is
supposed
to mean.  I think a better self-documenting place holder would be:

  type Months is
(PlaceHolderSoThatValuesReturnedByAdaCalendarMonthWillLineUpWithThisType,
                  Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov,
Dec);

Frank

PS.

I case someone can't figure it out, that was really a joke.  But the more I
think about
it, it would probably be alright because no one is going to use the actual
value.  For
initialization, you would be setting the variable to 'FIRST anyway.



^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2001-06-28 20:38 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-27  0:54 Ada95 calendar package question Vladimir Bednikov
2001-06-27  3:44 ` James Rogers
2001-06-27  8:32   ` Peter Hermann
2001-06-27 13:01     ` James Rogers
2001-06-27 14:01       ` Wes Groleau
2001-06-27 13:24     ` Marin David Condic
2001-06-27 13:59       ` Wes Groleau
2001-06-27 14:36         ` Marin David Condic
2001-06-27 15:17           ` Ted Dennison
2001-06-27 15:43           ` Frank
2001-06-27 16:07             ` Aron Felix Gurski
2001-06-27 15:59           ` Philip Anderson
2001-06-27 16:20             ` Ted Dennison
2001-06-27 17:39             ` M. A. Alves
2001-06-27 18:23             ` Wes Groleau
2001-06-27 14:38         ` Noé Lavallée
2001-06-27 14:32       ` Ian Wild
2001-06-27 22:37       ` Ehud Lamm
2001-06-28 13:17         ` Marin David Condic
2001-06-28 14:33           ` Wes Groleau
2001-06-28 20:38             ` Ehud Lamm
2001-06-28 11:27       ` Alfred Hilscher
2001-06-28 14:17         ` Ted Dennison
2001-06-28 14:49           ` Marin David Condic
2001-06-28 16:28             ` M. A. Alves
2001-06-27 14:56   ` Larry Kilgallen
2001-06-27 13:14 ` Marin David Condic
2001-06-27 14:24 ` Samuel T. Harris
2001-06-28  1:57 ` Jeffrey Carter
     [not found] <Pine.LNX.4.21.0106271731050.8027-100000@borba.ncc.up.pt>
2001-06-27 16:44 ` David C. Hoos
2001-06-28  8:29   ` Philip Anderson
  -- strict thread matches above, loose matches on Subject: below --
2001-06-27 20:39 Beard, Frank
2001-06-27 21:25 ` Larry Hazel
2001-06-27 21:55 Beard, Frank

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox