1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 17:40:06 +08:00

fix(mail): fix date format

This commit is contained in:
Shidong Wang 2021-10-24 15:23:52 +08:00
parent 6adb53df7b
commit 17aac81445
No known key found for this signature in database
GPG Key ID: 41BB7053E835C848
2 changed files with 44 additions and 6 deletions

View File

@ -22,15 +22,53 @@ function! mail#client#connect(ip, port)
endfunction endfunction
" Wed, 06 Sep 2017 02:55:41 +0000 ===> 2017-09-06 " Wed, 06 Sep 2017 02:55:41 +0000 ===> 2017-09-06
" 一月份JAN.  Jan.=January
" 二月份FEB.  Feb.=February
" 三月份MAR.  Mar.=March
" 四月份APR.  Apr.=April
" 五月份MAY    May=May
" 六月份JUN.  Jun.=June
" 七月份JUL.  Jul.=July
" 八月份AUG.  Aug.=August
" 九月份SEP.  Sept.=September
" 十月份OCT.  Oct.=October
" 十一月份NOV. Nov.=November
" 十二月份DEC. Dec.=December
let s:__months = { let s:__months = {
\ 'Jan' : 1,
\ 'Feb' : 2,
\ 'Mar' : 3,
\ 'Apr' : 4,
\ 'May' : 5,
\ 'Jun' : 6,
\ 'Jul' : 7,
\ 'Aug' : 8,
\ 'Sep' : 9, \ 'Sep' : 9,
\ 'Oct' : 10,
\ 'Nov' : 11,
\ 'Dec' : 12,
\ } \ }
let s:__week = {
\ 'Sun' : 7,
\ 'Mon' : 1,
\ 'Tue' : 2,
\ 'Wed' : 3,
\ 'Thu' : 4,
\ 'Fri' : 5,
\ 'Sat' : 6,
\ }
" Date: Sun, 24 Oct 2021 05:56:21 +0000
" Date: 23 Oct 2021 18:55:36 +0800
" Date: Wed, 13 Oct 2021 14:00:24 +0800 (CST)
function! s:convert(date) abort function! s:convert(date) abort
let info = split(a:date, ' ') let week = matchstr(a:date, '^\(Sun\|Mon\|Tue\|Wed\|Thu\|Fri\|Sat\)')
let year = info[3] let day = matchstr(a:date, '\d\+')
let m = get(s:__months, info[2], 00) let mounth = get(s:__months, matchstr(a:date, '\d\+\s\zs\S\+'), '00')
let day = len(info[1]) == 1 ? '0' . info[1] : info[1] let year = matchstr(a:date, '\d\+\s\S\+\s\zs\d\+')
return join([year, m, day], '-') let time = matchstr(a:date, '\d\+:\d\+:\d\+')
return printf('%04d-%02d-%02d', year, mounth, day) . ' ' . time
endfunction endfunction
function! s:noop(id) abort function! s:noop(id) abort

View File

@ -60,7 +60,7 @@ endfunction
function! s:refresh() abort function! s:refresh() abort
let mails = mail#client#mailbox#get(s:win_dir) let mails = mail#client#mailbox#get(s:win_dir)
let lines = ['DATA FROM SUBJECT'] let lines = ['DATA FROM SUBJECT']
for id in keys(mails) for id in keys(mails)
call add(lines, mails[id]['data'] . ' ' . s:encode(mails[id]['from']) . ' ' . s:encode(mails[id]['subject'])) call add(lines, mails[id]['data'] . ' ' . s:encode(mails[id]['from']) . ' ' . s:encode(mails[id]['subject']))
endfor endfor