When sending automated emails, it is useful if the system sends the time the server was started, and how long it has been up.
Write a method, calcUptime which is given two Strings which describe the time the server was started and the current time, and calculates the amount time the system has been "up". The time the system was started and the current time (now) will be given in the following format:
day month year at hh:mm:ss AM/PM
The day of the month will be between 1 and 31, inclusive, (or 30, 29, or 28, depending on the month and year). Month will be a 3-letter abbreviation (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec.) hh, mm, and ss will always be two digits, with leading zeros if less than 10. Year will be between 1900 and 2199, inclusive. The word 'at' will always be in lower case, and either AM or PM (always upper case) will always be present. (Note that 12:00 PM is considered noon and 12:00 AM is considered midnight of the day that is just starting.)
For example:
7 Jun 2004 at 04:41:32 PM
Your method should return a String in the following format:
#d #h #m #s
where each number is immediately adjacent to the units that it represents. Numbers should not have a leading zero. If any of the numbers are zero, omit that section. The maximum number of seconds returned is 59, the maximum number of minutes returned is 59, the maximum number of hours returned is 23, and there is no maximum number of days.
For example, an uptime period of zero days, 16 hours 36 minutes and zero seconds would be represented as:
16h 36m
|