Fortran

Guide To Learn

Happy Birthday! A countdown app

Do one thing and do it well.

  –A UNIX philosophy

Our project for this chapter is a minimal countdown app for the command line. Following the old UNIX philosophy, it will do one thing and do it well. The app will read a year, month, and day as command-line arguments input by the user. If the date input is today (according to the local machine time), the app will wish the user happy birthday. Otherwise, it will display the number of days, hours, minutes, and seconds remaining until the user’s birthday.

My birthday is on December 10, and running the app on the day of this writing gives me

$ ./countdown 2020 12 10
305 days, 4 hours, 41 minutes, and 16 seconds remaining until your Birthday!

However, if I wait 305 more days and run the app then, it will greet me as I expect it to:

$ ./countdown 2020 12 10
Happy Birthday!

Um, that’s the whole app. What more do you expect of something that does only one thing?

Happy Birthday! A countdown app

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top