Add time_format variable for customizing talk time (#353)

* Add `time_format` variable to `config.toml`
   * Enables customizing talk time between am/pm or 24h format
* Correct Go date format URL in documentation
This commit is contained in:
Serge Bibauw 2017-10-26 20:33:02 +02:00 committed by gcushen
commit 45b2e054e7
4 changed files with 9 additions and 7 deletions

View file

@ -69,9 +69,11 @@ defaultContentLanguageInSubdir = false
latitude = "37.4275"
longitude = "-122.1697"
# Date format (refer to Go's date format: http://flippinggodateformat.com )
# Date and time format (refer to Go's date format: http://fuckinggodateformat.com )
# Examples: "Mon, Jan 2, 2006" or "2006-01-02"
date_format = "Jan 2, 2006"
# Examples: "3:04 pm" or "15:04"
time_format = "3:04 PM"
# Show estimated reading time for posts?
reading_time = true
@ -143,7 +145,7 @@ defaultContentLanguageInSubdir = false
# Configuration of publication pages.
[params.publications]
# Date format (refer to Go's date format: http://flippinggodateformat.com )
# Date format (refer to Go's date format: http://fuckinggodateformat.com )
# Examples: "Mon, Jan 2, 2006" or "2006-01-02"
date_format = "January, 2006"

View file

@ -33,9 +33,9 @@
<div class="talk-metadata" itemprop="startDate">
{{ $date := .Params.time_start | default .Date }}
{{ (time $date).Format $.Site.Params.date_format }}
{{ (time $date).Format "3:04 PM" }}
{{ (time $date).Format ($.Site.Params.time_format | default "3:04 PM") }}
{{ with .Params.time_end }}
&mdash; {{ (time .).Format "3:04 PM" }}
&mdash; {{ (time .).Format ($.Site.Params.time_format | default "3:04 PM") }}
{{ end }}
</div>

View file

@ -4,7 +4,7 @@
<div itemprop="startDate">
{{ $date := .Params.time_start | default .Date }}
{{ (time $date).Format $.Site.Params.date_format }}
{{ (time $date).Format "3:04 PM" }}
{{ (time $date).Format ($.Site.Params.time_format | default "3:04 PM") }}
</div>
<div class="talk-metadata">
{{ if .Params.event_short }}

View file

@ -34,9 +34,9 @@
{{ $date := .Params.time_start | default .Date }}
{{ (time $date).Format $.Site.Params.date_format }}
<div class="talk-time">
{{ (time $date).Format "3:04 PM" }}
{{ (time $date).Format ($.Site.Params.time_format | default "3:04 PM") }}
{{ with .Params.time_end }}
&mdash; {{ (time .).Format "3:04 PM" }}
&mdash; {{ (time .).Format ($.Site.Params.time_format | default "3:04 PM") }}
{{ end }}
</div>
</div>