Problem Β· String

Days Since Last Login 🐠

Learn this problem
● EasyAlarmINTERNOA

Problem statement

At Alarm.com we need a new piece of functionality that will tell us how many days it's been since a user last logged into our site. Our product manager has given us the following requirements that they would like implemented so that we can start tracking inactive users.

Minimally Viable Product

  • Input should be a string in the format "MM/dd/yyyy"
  • The input should be converted to a date and subtracted from today's date
  • Return the absolute whole number of days as a string
  • Things to consider

  • If the input does not contain any characters or is only whitespace then return error code "E8430"
  • If the input is in the wrong format return error code "E9021"
  • If the input is in the correct format but not a valid date then return error code "E1756"
  • Function

    daysSinceLastLogin(lastLoginDate: String) β†’ String

    Examples

    Example 1

    lastLoginDate = "07/06/2022"return = "1"
    Input = "07/06/2022" Today = 07/07/2022 Output = "1"

    Example 2

    lastLoginDate = "02/30/2020"return = "E1756"
    The input "02/30/2020" is in the correct format but not a valid date because February does not have 30 days. Therefore, the function returns the error code "E1756". (By Tomtato. If you find it wrong, pls lmk! THX 🩡!)

    Constraints

    Unknown for now..

    More Alarm problems

    drafts saved locally
    public String daysSinceLastLogin(String lastLoginDate) {
      // write your code here
    }
    
    lastLoginDate"07/06/2022"
    expected"1"
    checking account