Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
3 deleted 3 characters in body
source | link

Java 8, 197 195195 157 bytes

n->(n<60?n+" second":n<3600?(n/=60)+"<60?n+" minute":n<86400?(n/=3600=60)+"<24?n+" hour":n<604800?(n/=86400=24)+"<7?n+" day":n<2678400n<31?(n/=604800=7)+" week":n<31536e3n<365?(n/=2678400=31)+" month":(n/=31536e3=365)+" year")+(n>1?"s":"")

-38 bytes thanks to @OlivierGrégoire.

Try it online.Try it online.

n->               // Method with long parameter and String return-type
  (n<60?          //  If `n` is below 60:
    n             //   Output `n`
    +" second"    //   + " second"
   :n<3600(n/=60)<60?       //  Else-if `n` is below 60*60
    (n/=60)             //   Integer-divide `n` by 60, and output it
    +" minute"    //   + " minute"
   :n<86400(n/=60)<24?      //  Else-if `n` is below 60*60*24:
    (n/=3600)             //   Integer-divide `n` by 60*60, and output it
    +" hour"      //   + " hour"
   :n<604800(n/=24)<7?     //  Else-if `n` is below 60*60*24*7:
    (n/=86400)             //   Integer-divide `n` by 60*60*24, and output it
    +" day"       //   + " day"
   :n<2678400n<31?         //  Else-if `n` is below 60*60*24*31:
    (n/=604800=7)        //   Integer-divide `n` by 60*60*24*7, and output it
    +" week"      //   + " week"
   :n<31536e3n<365?        //  Else-if `n` is below 60*60*24*365:
    (n/=2678400=31)       //   Integer-divide `n` by 60*60*24*31, and output it
    +" month"     //   + " month"
   :              //  Else:
    (n/=31536e3=365)      //   Integer-divide `n` by 60*60*24*365, and output it
    +" year")     //   + " year"
   +(n>1?"s":"")  //  And add a trailing (plural) "s" if (the new) `n` is larger than 1

Java 8, 197 195 bytes

n->(n<60?n+" second":n<3600?(n/=60)+" minute":n<86400?(n/=3600)+" hour":n<604800?(n/=86400)+" day":n<2678400?(n/=604800)+" week":n<31536e3?(n/=2678400)+" month":(n/=31536e3)+" year")+(n>1?"s":"")

Try it online.

n->               // Method with long parameter and String return-type
  (n<60?          //  If `n` is below 60:
    n             //   Output `n`
    +" second"    //   + " second"
   :n<3600?       //  Else-if `n` is below 60*60
    (n/=60)       //   Integer-divide `n` by 60, and output it
    +" minute"    //   + " minute"
   :n<86400?      //  Else-if `n` is below 60*60*24:
    (n/=3600)     //   Integer-divide `n` by 60*60, and output it
    +" hour"      //   + " hour"
   :n<604800?     //  Else-if `n` is below 60*60*24*7:
    (n/=86400)    //   Integer-divide `n` by 60*60*24, and output it
    +" day"       //   + " day"
   :n<2678400?    //  Else-if `n` is below 60*60*24*31:
    (n/=604800)   //   Integer-divide `n` by 60*60*24*7, and output it
    +" week"      //   + " week"
   :n<31536e3?    //  Else-if `n` is below 60*60*24*365:
    (n/=2678400)  //   Integer-divide `n` by 60*60*24*31, and output it
    +" month"     //   + " month"
   :              //  Else:
    (n/=31536e3)  //   Integer-divide `n` by 60*60*24*365, and output it
    +" year")     //   + " year"
   +(n>1?"s":"")  //  And add a trailing (plural) "s" if (the new) `n` is larger than 1

Java 8, 197 195 157 bytes

n->(n<60?n+" second":(n/=60)<60?n+" minute":(n/=60)<24?n+" hour":(n/=24)<7?n+" day":n<31?(n/=7)+" week":n<365?(n/=31)+" month":(n/=365)+" year")+(n>1?"s":"")

-38 bytes thanks to @OlivierGrégoire.

Try it online.

n->               // Method with long parameter and String return-type
  (n<60?          //  If `n` is below 60:
    n             //   Output `n`
    +" second"    //   + " second"
   :(n/=60)<60?   //  Else-if `n` is below 60*60
    n             //   Integer-divide `n` by 60, and output it
    +" minute"    //   + " minute"
   :(n/=60)<24?   //  Else-if `n` is below 60*60*24:
    n             //   Integer-divide `n` by 60*60, and output it
    +" hour"      //   + " hour"
   :(n/=24)<7?    //  Else-if `n` is below 60*60*24*7:
    n             //   Integer-divide `n` by 60*60*24, and output it
    +" day"       //   + " day"
   :n<31?         //  Else-if `n` is below 60*60*24*31:
    (n/=7)        //   Integer-divide `n` by 60*60*24*7, and output it
    +" week"      //   + " week"
   :n<365?        //  Else-if `n` is below 60*60*24*365:
    (n/=31)       //   Integer-divide `n` by 60*60*24*31, and output it
    +" month"     //   + " month"
   :              //  Else:
    (n/=365)      //   Integer-divide `n` by 60*60*24*365, and output it
    +" year")     //   + " year"
   +(n>1?"s":"")  //  And add a trailing (plural) "s" if (the new) `n` is larger than 1
2 deleted 14 characters in body
source | link

Java 8, 197197 195 bytes

n->(n<60?n+" second":n<3600?(n/=60)+" minute":n<86400?(n/=3600)+" hour":n<604800?(n/=86400)+" day":n<2678400?(n/=604800)+" week":n<31536000n<31536e3?(n/=2678400)+" month":(n/=31536000=31536e3)+" year")+(n>1?"s":"")

Try it online.Try it online.

n->                // Method with long parameter and String return-type
  (n<60?           //  If `n` is below 60:
    n              //   Output `n`
    +" second"     //   + " second"
   :n<3600?        //  Else-if `n` is below 60*60
    (n/=60)        //   Integer-divide `n` by 60, and output it
    +" minute"     //   + " minute"
   :n<86400?       //  Else-if `n` is below 60*60*24:
    (n/=3600)      //   Integer-divide `n` by 60*60, and output it
    +" hour"       //   + " hour"
   :n<604800?      //  Else-if `n` is below 60*60*24*7:
    (n/=86400)     //   Integer-divide `n` by 60*60*24, and output it
    +" day"        //   + " day"
   :n<2678400?     //  Else-if `n` is below 60*60*24*31:
    (n/=604800)    //   Integer-divide `n` by 60*60*24*7, and output it
    +" week"       //   + " week"
   :n<31536000n<31536e3?    //  Else-if `n` is below 60*60*24*365:
    (n/=2678400)   //   Integer-divide `n` by 60*60*24*31, and output it
    +" month"      //   + " month"
   :               //  Else:
    (n/=31536000=31536e3)  //   Integer-divide `n` by 60*60*24*365, and output it
    +" year")      //   + " year"
   +(n>1?"s":"")   //  And add a trailing (plural) "s" if (the new) `n` is larger than 1

Java 8, 197 bytes

n->(n<60?n+" second":n<3600?(n/=60)+" minute":n<86400?(n/=3600)+" hour":n<604800?(n/=86400)+" day":n<2678400?(n/=604800)+" week":n<31536000?(n/=2678400)+" month":(n/=31536000)+" year")+(n>1?"s":"")

Try it online.

n->                // Method with long parameter and String return-type
  (n<60?           //  If `n` is below 60:
    n              //   Output `n`
    +" second"     //   + " second"
   :n<3600?        //  Else-if `n` is below 60*60
    (n/=60)        //   Integer-divide `n` by 60, and output it
    +" minute"     //   + " minute"
   :n<86400?       //  Else-if `n` is below 60*60*24:
    (n/=3600)      //   Integer-divide `n` by 60*60, and output it
    +" hour"       //   + " hour"
   :n<604800?      //  Else-if `n` is below 60*60*24*7:
    (n/=86400)     //   Integer-divide `n` by 60*60*24, and output it
    +" day"        //   + " day"
   :n<2678400?     //  Else-if `n` is below 60*60*24*31:
    (n/=604800)    //   Integer-divide `n` by 60*60*24*7, and output it
    +" week"       //   + " week"
   :n<31536000?    //  Else-if `n` is below 60*60*24*365:
    (n/=2678400)   //   Integer-divide `n` by 60*60*24*31, and output it
    +" month"      //   + " month"
   :               //  Else:
    (n/=31536000)  //   Integer-divide `n` by 60*60*24*365, and output it
    +" year")      //   + " year"
   +(n>1?"s":"")   //  And add a trailing (plural) "s" if (the new) `n` is larger than 1

Java 8, 197 195 bytes

n->(n<60?n+" second":n<3600?(n/=60)+" minute":n<86400?(n/=3600)+" hour":n<604800?(n/=86400)+" day":n<2678400?(n/=604800)+" week":n<31536e3?(n/=2678400)+" month":(n/=31536e3)+" year")+(n>1?"s":"")

Try it online.

n->               // Method with long parameter and String return-type
  (n<60?          //  If `n` is below 60:
    n             //   Output `n`
    +" second"    //   + " second"
   :n<3600?       //  Else-if `n` is below 60*60
    (n/=60)       //   Integer-divide `n` by 60, and output it
    +" minute"    //   + " minute"
   :n<86400?      //  Else-if `n` is below 60*60*24:
    (n/=3600)     //   Integer-divide `n` by 60*60, and output it
    +" hour"      //   + " hour"
   :n<604800?     //  Else-if `n` is below 60*60*24*7:
    (n/=86400)    //   Integer-divide `n` by 60*60*24, and output it
    +" day"       //   + " day"
   :n<2678400?    //  Else-if `n` is below 60*60*24*31:
    (n/=604800)   //   Integer-divide `n` by 60*60*24*7, and output it
    +" week"      //   + " week"
   :n<31536e3?    //  Else-if `n` is below 60*60*24*365:
    (n/=2678400)  //   Integer-divide `n` by 60*60*24*31, and output it
    +" month"     //   + " month"
   :              //  Else:
    (n/=31536e3)  //   Integer-divide `n` by 60*60*24*365, and output it
    +" year")     //   + " year"
   +(n>1?"s":"")  //  And add a trailing (plural) "s" if (the new) `n` is larger than 1
1
source | link

Java 8, 197 bytes

n->(n<60?n+" second":n<3600?(n/=60)+" minute":n<86400?(n/=3600)+" hour":n<604800?(n/=86400)+" day":n<2678400?(n/=604800)+" week":n<31536000?(n/=2678400)+" month":(n/=31536000)+" year")+(n>1?"s":"")

Explanation:

Try it online.

n->                // Method with long parameter and String return-type
  (n<60?           //  If `n` is below 60:
    n              //   Output `n`
    +" second"     //   + " second"
   :n<3600?        //  Else-if `n` is below 60*60
    (n/=60)        //   Integer-divide `n` by 60, and output it
    +" minute"     //   + " minute"
   :n<86400?       //  Else-if `n` is below 60*60*24:
    (n/=3600)      //   Integer-divide `n` by 60*60, and output it
    +" hour"       //   + " hour"
   :n<604800?      //  Else-if `n` is below 60*60*24*7:
    (n/=86400)     //   Integer-divide `n` by 60*60*24, and output it
    +" day"        //   + " day"
   :n<2678400?     //  Else-if `n` is below 60*60*24*31:
    (n/=604800)    //   Integer-divide `n` by 60*60*24*7, and output it
    +" week"       //   + " week"
   :n<31536000?    //  Else-if `n` is below 60*60*24*365:
    (n/=2678400)   //   Integer-divide `n` by 60*60*24*31, and output it
    +" month"      //   + " month"
   :               //  Else:
    (n/=31536000)  //   Integer-divide `n` by 60*60*24*365, and output it
    +" year")      //   + " year"
   +(n>1?"s":"")   //  And add a trailing (plural) "s" if (the new) `n` is larger than 1