Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

description For this assignment, you will improve upon your previous work in HW1, adding command-line options, and reading from files or standard input. Arguments The

description

For this assignment, you will improve upon your previous work in HW1, adding command-line options, and reading from files or standard input.

Arguments

The first command-line arguments should be options:

-f format

Specify the format, to be given to strftime(). For example, a format of "%A %B %d" would give output of Friday March 03 for a date of today.

-i

Specify a format that will write the date in the ISO 8601 format of YYYY-MM-DD, exactly four digits (year), a hyphen, exactly two digits (month), another hyphen, and exactly two more digits (day of month). Today would produce 2023-03-03.

-v

Announce, to standard output, each file as it is read. Display *** Processing filename for each file, and *** Processing standard input for standard input.

Any remaining arguments are files that should contain one date per line. If no files are given, then read from standard input.

Input Format

Input lines can be in any of these formats:

year.day

As in HW1. The year should be 1year9999, and the day is either 1day365 or 1day366, depending on leap year. Today is 2023.062.

YYYY-MM-DD

YYYY is a four digit year. MM is a two-digit month. DD is a two digit day. Today is 2023-03-03. YYYY should be 1YYYY9999, MM should be 1MM12, and DD should 1 to however many days are in that month that year.

today

The current day. Literally, the five characters today, in either case. E.g., tOdAy is valid.

yesterday

The day before today. Literally, the nine characters yesterday, in either case. E.g., YEstERday is valid.

tomorrow

The day after today. Literally, the eight characters tomorrow, in either case. E.g., TomORRow is valid.

Output Format

For each input line, translate it using the given format, and write it to standard output, followed by a newline.

Sample Runs

Here are sample runs, where % is my prompt.

% cat pearl 1941-12-07 00000000001941.00000341 % cat limits 1.1 0001-01-01 9999.365 9999-12-31 % echo ToDay | ./hw3 Mon Feb 20 2023 % echo YESterDaY | ./hw3 -f 'Day %d of the month of %B of the year %Y' Day 19 of the month of February of the year 2023 % echo 2023.1 | ./hw3 -f 'Week-based year: %G%nConventional year: %Y' Week-based year: 2022 Conventional year: 2023 % ./hw3 -f"A day that will live in infamy: %A %B %e %Y" -v pearl *** Processing pearl A day that will live in infamy: Sunday December 7 1941 A day that will live in infamy: Sunday December 7 1941 % ./hw3 -f"A day that will live in infamy: %A %B %e %Y" -v                         

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

Students also viewed these Databases questions

Question

What must a creditor do to become a secured party?

Answered: 1 week ago

Question

When should the last word in a title be capitalized?

Answered: 1 week ago