commit 036a7d24f948b43a37effc238502acd1dc365979
parent 8c7937c7655e8cd74b59cfafcdf272c72725a81b
Author: yhu266 <56977205+yhu266@users.noreply.github.com>
Date: Mon, 28 Dec 2020 17:27:54 -0800
Add option to configure date string format
Diffstat:
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git 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
@@ -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
@@ -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 <CR> and <S-CR> in insert mode
* Feature: enable re-mapping insert mode table mappings