> function getDateShortName(s, shortYear=true) {
...     let parts = s.split(/\s+/ig)
...     
...     if(shortYear) {
.....         return parts[0].slice(0, 3) + '\'' + parts[1].slice(2)
.....     } else {
.....         return parts[0].slice(0, 3) + '\'' + parts[1]
.....     }
... }
undefined
> 
> getDateShortName("January 2020")
"Jan'20"
> 
> getDateShortName("January 2020", false)
"Jan'2020"
> 
> getDateShortName("February  2021")
"Feb'21"
> 
> getDateShortName("February  2021", false)
"Feb'2021"
> 
> getDateShortName("February  2021", true)
"Feb'21"
> 
> 
          Last active
          March 22, 2020 18:27 
        
      - 
      
 - 
        
Save hygull/5ae2f0dbef5331a0b6d7e6dc4bc20f92 to your computer and use it in GitHub Desktop.  
    Conversion of a simple Month Year string to short form
  
        
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment