Time of day as conditional in Vim
I'm working on improving my .vimrc
, and I want to have command inside of it that depends upon whether it is night or day. I'd like to have something like the following in the end:
if isNightTime
" do something
else
" some other thing
endif
What's the best way to go about this?
Using the strftime() funtion is probably the best approach. If you are satsified with one-hour resolution, you could do something like this:
let hour = strftime("%H")
if 6 <= hour && hour < 18
" do daytime stuff
else
" do nighttime stuff
endif
See
:help strftime()
and the strftime man page.