[Tutor] PLEASE HELP

Neil Cerutti neilc at norwich.edu
Fri Apr 13 10:24:33 EDT 2018


On 2018-04-12, Scharrer, Brianna <bscharrer at luc.edu> wrote:
> Applications of basic language syntax
>
> Date/time string parsing
>
> Time stamps on data are often recorded in the standard ISO date
> and time format as shown below
>
> yyyy-mm-ddThh:mm:ss
>
> 2018-01-02T18:31:16 ----> 6:31pm on January 2, 2018
>
> 1999-02-14T21:02:37 ----> 9:02pm on February 14, 1999
>
> Write code that when given a datetime string and outputs a
> human readable version exactly in the format specified below.

I disagree that the first version isn't human readable. It is
both human readable and stores the date/time in lexicographic
order, which is extremly useful for both humans and machines.

> [Morning, Noon, Afternoon, Evening, or Night], X:XX[am or pm] on [Month as a word] [day], [year]
>
> E.g. 1999-02-14T21:02:37 would be ?Night, 9:02pm on February 14, 1999?

You will need to ask for clarification from your teacher for the
deliniation between morning, noon, afternoon, evening and night.
There's no international standard I'm aware of.

>
> Do not use any datetime string function, though depending on
> your language they would be useful to do this in practice.

They certainly would!

> Hint: you?ll have to cast strings to integers in order to
> perform the if statements which place [Morning, Noon?], [am or
> pm] and [Month as a word] appropriately.

With the exception of converting string to integer (as Alan
discussed) I recommend using a dictionaries for conversion,
rather than if statements, if you're allowed.

-- 
Neil Cerutti



More information about the Tutor mailing list