Skip to content

Commit

Permalink
Allow for setting date format with a variable.
Browse files Browse the repository at this point in the history
Closes issue #44.
  • Loading branch information
cgiacofei authored and kljohann committed Apr 23, 2017
1 parent c27980b commit 9850f4d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion autoload/ledger.vim
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function! ledger#transaction_date_set(lnum, type, ...) "{{{1
return
endif

let formatted = strftime('%Y/%m/%d', time)
let formatted = strftime(g:ledger_date_format, time)
if has_key(trans, 'date') && ! empty(trans['date'])
let date = split(trans['date'], '=')
else
Expand Down
4 changes: 4 additions & 0 deletions doc/ledger.txt
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ behaviour of the ledger filetype.

let g:ledger_commodity_sep = ''

* Format of transaction date:

let g:ledger_date_format = '%Y/%m/%d'

* The file to be used to generate reports:

let g:ledger_main = '%'
Expand Down
6 changes: 5 additions & 1 deletion ftplugin/ledger.vim
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ if !exists('g:ledger_extra_options')
let g:ledger_extra_options = ''
endif

if !exists('g:ledger_date_format')
let g:ledger_date_format = '%Y/%m/%d'
endif

" You can set a maximal number of columns the fold text (excluding amount)
" will use by overriding g:ledger_maxwidth in your .vimrc.
" When maxwidth is zero, the amount will be displayed at the far right side
Expand Down Expand Up @@ -288,7 +292,7 @@ function! LedgerComplete(findstart, base) "{{{1
let update_cache = 1
endif
elseif b:compl_context == 'new' "{{{2 (new line)
return [strftime('%Y/%m/%d')]
return [strftime(g:ledger_date_format)]
endif "}}}


Expand Down

0 comments on commit 9850f4d

Please sign in to comment.