Skip to content

Instantly share code, notes, and snippets.

@Torthu
Created January 30, 2014 14:13
Show Gist options
  • Select an option

  • Save Torthu/8709215 to your computer and use it in GitHub Desktop.

Select an option

Save Torthu/8709215 to your computer and use it in GitHub Desktop.
Very naive class for getting localised "short dates" on the form "30. jan" when you cannot trust locale.
DateUtil = {
getShortDate: ->
date = new Date()
return date.getDate() + '. ' + @_monthName(date.getMonth()).substring(0,3).toLowerCase()
_monthName: (monthId) ->
@months = {
0: 'Januar'
1: 'Februar'
2: 'Mars'
3: 'April'
4: 'Mai'
5: 'Juni'
6: 'Juli'
7: 'August'
8: 'September'
9: 'Oktober'
10: 'November'
11: 'Desember'
}
if @months[monthId]
return @months[monthId]
else
return ''
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment