cjmoberg
cjmoberg

Reputation: 106

ADA : Convert an input with slashes to 3 seperate integers

How would I go about reading in an input that looks like "01/12/1997" to 3 seperate integers that are 01, 12, and 1997?

Upvotes: 0

Views: 110

Answers (3)

cjmoberg
cjmoberg

Reputation: 106

I ended up adding 3 more variables, all strings. I then set them as Date(1..2) and Month(4..5) and Year(7..10), then I converted them all to integers and continued my program. Not the best way, but it worked.

Upvotes: 0

manuBriot
manuBriot

Reputation: 2715

And just in case your question was an intermediate step on the way to parsing dates, you should take a look at GNAT.Calendar.Time_IO.Value which knows about parsing various dates formats.

Upvotes: 1

Marc C
Marc C

Reputation: 8522

If using GNAT, you can use GNAT.String_Split, followed by the 'Value attribute conversion.

Upvotes: 1

Related Questions