itchyny / calendar.vim

A calendar application for Vim
MIT License
1.95k stars 72 forks source link

VimL interface #40

Closed mMontu closed 10 years ago

mMontu commented 10 years ago

First of all, thank you very much for this awesome plugin!

I'm creating some Ultisnip snippets for vimwiki files and I'm looking for some time/date functions that are certainly present on this plugin.

I've started browsing the code, but it is rather larger than I first guessed. Are there any functions that can be used on VimL code? In special, returning the current day of week (as a number or any other representation) and dd/mm representations (or any similar, as it could be swapped by substitute()) relative to 'today'? (e.g.: echo functionX(0): 10/02, echo functionX(2): 12/02, echo functionX(-10): 31/01)

itchyny commented 10 years ago

Try echo calendar#day#today().get_ymd(). It returns in the form of [year, month, day]. The date of tomorrow can be obtained by echo calendar#day#today().add(1).get_ymd(). Also, try ... add(-10).....

mMontu commented 10 years ago

I had tried echo calendar#day#today(), but I've missed the additional methods you pointed. add(), get_ymd() and week() are exactly what I was looking for.

Thank you very much!