Module: Jekyll::DateDe

Defined in:
lib/jekyll/date_de.rb

Constant Summary collapse

MONTHNAMES_DE =

Deutsche Lokalisation:

[nil,
"Januar", "Februar", "März", "April", "Mai", "Juni",
"Juli", "August", "September", "Oktober", "November", "Dezember" ]
ABBR_MONTHNAMES_DE =
[nil,
"Jan", "Feb", "Mär", "Apr", "Mai", "Jun",
"Jul", "Aug", "Sep", "Okt", "Nov", "Dez" ]
DAYNAMES_DE =
[
"Sonntag", "Montag", "Dienstag", "Mittwoch",
"Donnerstag", "Freitag", "Samstag" ]
ABBR_DAYNAMES_DE =
[
"So", "Mo", "Di", "Mi",
"Do", "Fr", "Sa" ]

Instance Method Summary collapse

Instance Method Details

#datetime(date) ⇒ Object

Returns a datetime if the input is a string



24
25
26
27
28
29
# File 'lib/jekyll/date_de.rb', line 24

def datetime(date)
  if date.class == String
    date = Time.parse(date)
  end
  date
end

#format_date(date, format) ⇒ Object

Formats date by given date format



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/jekyll/date_de.rb', line 32

def format_date(date, format)
  date = datetime(date)
    if format.nil? || format.empty? || format == "ordinal"
      date_formatted = ordinalize(date)
    else
      format.gsub!(/%a/, ABBR_DAYNAMES_DE[date.wday])
      format.gsub!(/%A/, DAYNAMES_DE[date.wday])
      format.gsub!(/%b/, ABBR_MONTHNAMES_DE[date.mon])
      format.gsub!(/%B/, MONTHNAMES_DE[date.mon])
      date_formatted = date.strftime(format)
    end
    date_formatted
end

#full_date_de(date) ⇒ Object

Usage: post.date | full_date_de } Result: 13. Dezember 2017



48
49
50
# File 'lib/jekyll/date_de.rb', line 48

def full_date_de(date)
  format_date(date, "%d. %B %Y")
end