From 036a7d24f948b43a37effc238502acd1dc365979 Mon Sep 17 00:00:00 2001 From: yhu266 <56977205+yhu266@users.noreply.github.com> Date: Mon, 28 Dec 2020 17:27:54 -0800 Subject: [PATCH] Add option to configure date string format --- autoload/vimwiki/html.vim | 2 +- autoload/vimwiki/vars.vim | 1 + doc/vimwiki.txt | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index 48dd2ae..130bb39 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -1803,7 +1803,7 @@ function! s:convert_file_to_lines(wikifile, current_html_file) abort let result['template_name'] = template_name let result['title'] = s:process_title(placeholders, fnamemodify(a:wikifile, ':t:r')) - let result['date'] = s:process_date(placeholders, strftime('%Y-%m-%d')) + let result['date'] = s:process_date(placeholders, strftime(vimwiki#vars#get_wikilocal('template_date_format'))) let result['wiki_path'] = strpart(s:current_wiki_file, strlen(vimwiki#vars#get_wikilocal('path'))) return result diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index 4a5aba0..f4f1cb8 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -522,6 +522,7 @@ function! s:get_default_wikilocal() abort \ 'template_default': {'type': type(''), 'default': 'default', 'min_length': 1}, \ 'template_ext': {'type': type(''), 'default': '.tpl'}, \ 'template_path': {'type': type(''), 'default': $HOME . '/vimwiki/templates/'}, + \ 'template_date_format': {'type': type(''), 'default': '%Y-%m-%d'}, \ 'text_ignore_newline': {'type': type(0), 'default': 1, 'min': 0, 'max': 1}, \ 'tag_format': {'type': type({}), 'default': { \ 'pre': '^\|\s', diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 14ad33d..d2be18a 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -1691,7 +1691,8 @@ See |vimwiki-option-template_path| for details. %date *vimwiki-date* The date of the wiki page. The value can be used in the HTML template, see -|vimwiki-option-template_path| for details. +|vimwiki-option-template_path| for details. To set a specific date string +format, see |vimwiki-option-template_date_format| for details. %date 2017-07-08 %date @@ -2375,6 +2376,17 @@ Setup template filename extension. See |vimwiki-option-template_path| for details. +*vimwiki-option-template_date_format* +------------------------------------------------------------------------------ +Key Default value~ +template_date_format %Y-%m-%d + +Description~ +Setup date string format in templates. + +See |vimwiki-date| for details. + + *vimwiki-option-css_name* ------------------------------------------------------------------------------ Key Default value~ @@ -3865,6 +3877,7 @@ Contributors and their Github usernames in roughly chronological order: - Rajesh Sharem (@deepredsky) - Amit Beka (@amitbeka) - Yuuy Wei + - Yifan Hu (@yhu266) ============================================================================== 16. Changelog *vimwiki-changelog* @@ -3876,6 +3889,8 @@ http://code.google.com/p/vimwiki/issues/list. They may be accessible from https://github.com/vimwiki-backup/vimwiki/issues. New:~ + * Feature: Add option |vimwiki-option-template_date_format| to configure + alternative date string format * Feature: PR #686: add a flag lists_return to disable mappings to and in insert mode * Feature: enable re-mapping insert mode table mappings