Skip to content

Commit 9850f4d

Browse files
cgiacofeikljohann
authored andcommitted
Allow for setting date format with a variable.
Closes issue #44.
1 parent c27980b commit 9850f4d

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

autoload/ledger.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function! ledger#transaction_date_set(lnum, type, ...) "{{{1
3939
return
4040
endif
4141

42-
let formatted = strftime('%Y/%m/%d', time)
42+
let formatted = strftime(g:ledger_date_format, time)
4343
if has_key(trans, 'date') && ! empty(trans['date'])
4444
let date = split(trans['date'], '=')
4545
else

doc/ledger.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@ behaviour of the ledger filetype.
288288

289289
let g:ledger_commodity_sep = ''
290290

291+
* Format of transaction date:
292+
293+
let g:ledger_date_format = '%Y/%m/%d'
294+
291295
* The file to be used to generate reports:
292296

293297
let g:ledger_main = '%'

ftplugin/ledger.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ if !exists('g:ledger_extra_options')
4141
let g:ledger_extra_options = ''
4242
endif
4343

44+
if !exists('g:ledger_date_format')
45+
let g:ledger_date_format = '%Y/%m/%d'
46+
endif
47+
4448
" You can set a maximal number of columns the fold text (excluding amount)
4549
" will use by overriding g:ledger_maxwidth in your .vimrc.
4650
" When maxwidth is zero, the amount will be displayed at the far right side
@@ -288,7 +292,7 @@ function! LedgerComplete(findstart, base) "{{{1
288292
let update_cache = 1
289293
endif
290294
elseif b:compl_context == 'new' "{{{2 (new line)
291-
return [strftime('%Y/%m/%d')]
295+
return [strftime(g:ledger_date_format)]
292296
endif "}}}
293297

294298

0 commit comments

Comments
 (0)