Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTime: use strftime('%H %M', 0) on Windows #578

Merged
merged 6 commits into from
May 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions autoload/vital/__vital__/DateTime.vim
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ function! s:_vital_loaded(V) abort
let s:AM_PM_TIMES = map([0, 12],
\ 's:from_date(1970, 1, 1, v:val, 0, 0, 0).unix_time()')

if s:Prelude.is_windows()
let key = 'HKLM\System\CurrentControlSet\Control\TimeZoneInformation'
let regs = s:Process.system(printf('reg query "%s" /v Bias', key))
let time = matchstr(regs, 'REG_DWORD\s*\zs0x\x\+')
let s:win_tz = empty(time) ? 0 : s:Bitwise.sign_extension(time) / -s:NUM_MINUTES
endif

" default values
call extend(s:DateTime, {
\ '_year': 0,
Expand Down Expand Up @@ -804,7 +797,12 @@ endfunction
" TODO Use Prelude.is_windows() to avoid duplicate
if has('win16') || has('win32') || has('win64')
function! s:_default_tz() abort
return s:win_tz
let hm = map(split(strftime('%H %M', 0), ' '), 'str2nr(v:val)')
if str2nr(strftime('%Y', 0)) != 1970
let tz_sec = s:SECONDS_OF_DAY - hm[0] * s:SECONDS_OF_HOUR - hm[1] * s:NUM_SECONDS
return printf('-%02d%02d', tz_sec / s:SECONDS_OF_HOUR, (tz_sec / s:NUM_SECONDS) % s:NUM_MINUTES)
endif
return printf('+%02d%02d', hm[0], hm[1])
endfunction
else
function! s:_default_tz() abort
Expand Down