Skip to content

Instantly share code, notes, and snippets.

@Max-Makhrov
Forked from mattn/dump.vim
Last active May 27, 2020
Embed
What would you like to do?
google-calendar-holiday
scriptencoding utf-8
let s:calendar_list = [
\ ['Australian Holidays', 'en.australian#holiday@group.v.calendar.google.com'],
\ ['Austrian Holidays', 'en.austrian#holiday@group.v.calendar.google.com'],
\ ['Brazilian Holidays', 'en.brazilian#holiday@group.v.calendar.google.com'],
\ ['Canadian Holidays', 'en.canadian#holiday@group.v.calendar.google.com'],
\ ['China Holidays', 'en.china#holiday@group.v.calendar.google.com'],
\ ['Christian Holidays', 'en.christian#holiday@group.v.calendar.google.com'],
\ ['Danish Holidays', 'en.danish#holiday@group.v.calendar.google.com'],
\ ['Dutch Holidays', 'en.dutch#holiday@group.v.calendar.google.com'],
\ ['Finnish Holidays', 'en.finnish#holiday@group.v.calendar.google.com'],
\ ['French Holidays', 'en.french#holiday@group.v.calendar.google.com'],
\ ['German Holidays', 'en.german#holiday@group.v.calendar.google.com'],
\ ['Greek Holidays', 'en.greek#holiday@group.v.calendar.google.com'],
\ ['Hong Kong (C) Holidays', 'en.hong_kong_c#holiday@group.v.calendar.google.com'],
\ ['Hong Kong Holidays', 'en.hong_kong#holiday@group.v.calendar.google.com'],
\ ['Indian Holidays', 'en.indian#holiday@group.v.calendar.google.com'],
\ ['Indonesian Holidays', 'en.indonesian#holiday@group.v.calendar.google.com'],
\ ['Iranian Holidays', 'en.iranian#holiday@group.v.calendar.google.com'],
\ ['Irish Holidays', 'en.irish#holiday@group.v.calendar.google.com'],
\ ['Islamic Holidays', 'en.islamic#holiday@group.v.calendar.google.com'],
\ ['Italian Holidays', 'en.italian#holiday@group.v.calendar.google.com'],
\ ['Japanese Holidays', 'en.japanese#holiday@group.v.calendar.google.com'],
\ ['Jewish Holidays', 'en.jewish#holiday@group.v.calendar.google.com'],
\ ['Malaysian Holidays', 'en.malaysia#holiday@group.v.calendar.google.com'],
\ ['Mexican Holidays', 'en.mexican#holiday@group.v.calendar.google.com'],
\ ['New Zealand Holidays', 'en.new_zealand#holiday@group.v.calendar.google.com'],
\ ['Norwegian Holidays', 'en.norwegian#holiday@group.v.calendar.google.com'],
\ ['Philippines Holidays', 'en.philippines#holiday@group.v.calendar.google.com'],
\ ['Polish Holidays', 'en.polish#holiday@group.v.calendar.google.com'],
\ ['Portuguese Holidays', 'en.portuguese#holiday@group.v.calendar.google.com'],
\ ['Russian Holidays', 'en.russian#holiday@group.v.calendar.google.com'],
\ ['Singapore Holidays', 'en.singapore#holiday@group.v.calendar.google.com'],
\ ['South Africa Holidays', 'en.sa#holiday@group.v.calendar.google.com'],
\ ['South Korean Holidays', 'en.south_korea#holiday@group.v.calendar.google.com'],
\ ['Spain Holidays', 'en.spain#holiday@group.v.calendar.google.com'],
\ ['Swedish Holidays', 'en.swedish#holiday@group.v.calendar.google.com'],
\ ['Taiwan Holidays', 'en.taiwan#holiday@group.v.calendar.google.com'],
\ ['Thai Holidays', 'en.thai#holiday@group.v.calendar.google.com'],
\ ['UK Holidays', 'en.uk#holiday@group.v.calendar.google.com'],
\ ['US Holidays', 'en.usa#holiday@group.v.calendar.google.com'],
\ ['Ukraine Holidays', 'en.ukrainian#holiday@group.v.calendar.google.com']
\ ['Vietnamese Holidays', 'en.vietnamese#holiday@group.v.calendar.google.com'],
\ ['アイルランドの祝日', 'ja.irish#holiday@group.v.calendar.google.com'],
\ ['アメリカの祝日', 'ja.usa#holiday@group.v.calendar.google.com'],
\ ['イギリスの祝日', 'ja.uk#holiday@group.v.calendar.google.com'],
\ ['イスラム教の祝日', 'ja.islamic#holiday@group.v.calendar.google.com'],
\ ['イタリアの祝日', 'ja.italian#holiday@group.v.calendar.google.com'],
\ ['インドの祝日', 'ja.indian#holiday@group.v.calendar.google.com'],
\ ['インドネシアの祝日', 'ja.indonesian#holiday@group.v.calendar.google.com'],
\ ['オランダの祝日', 'ja.dutch#holiday@group.v.calendar.google.com'],
\ ['オーストラリアの祝日', 'ja.australian#holiday@group.v.calendar.google.com'],
\ ['オーストリアの祝日', 'ja.austrian#holiday@group.v.calendar.google.com'],
\ ['カナダの祝日', 'ja.canadian#holiday@group.v.calendar.google.com'],
\ ['キリスト教の祝日', 'ja.christian#holiday@group.v.calendar.google.com'],
\ ['ギリシャの祝日', 'ja.greek#holiday@group.v.calendar.google.com'],
\ ['シンガポールの祝日', 'ja.singapore#holiday@group.v.calendar.google.com'],
\ ['スウェーデンの祝日', 'ja.swedish#holiday@group.v.calendar.google.com'],
\ ['スペインの祝日', 'ja.spain#holiday@group.v.calendar.google.com'],
\ ['タイの祝日', 'ja.thai#holiday@group.v.calendar.google.com'],
\ ['デンマークの祝日', 'ja.danish#holiday@group.v.calendar.google.com'],
\ ['ドイツの祝日', 'ja.german#holiday@group.v.calendar.google.com'],
\ ['ニュージーランドの祝日', 'ja.new_zealand#holiday@group.v.calendar.google.com'],
\ ['ノルウェイの祝日', 'ja.norwegian#holiday@group.v.calendar.google.com'],
\ ['フィリピンの祝日', 'ja.philippines#holiday@group.v.calendar.google.com'],
\ ['フィンランドの祝日', 'ja.finnish#holiday@group.v.calendar.google.com'],
\ ['フランスの祝日', 'ja.french#holiday@group.v.calendar.google.com'],
\ ['ブラジルの祝日', 'ja.brazilian#holiday@group.v.calendar.google.com'],
\ ['ベトナムの祝日', 'ja.vietnamese#holiday@group.v.calendar.google.com'],
\ ['ポルトガルの祝日', 'ja.portuguese#holiday@group.v.calendar.google.com'],
\ ['ポーランドの祝日', 'ja.polish#holiday@group.v.calendar.google.com'],
\ ['マレーシアの祝日', 'ja.malaysia#holiday@group.v.calendar.google.com'],
\ ['メキシコの祝日', 'ja.mexican#holiday@group.v.calendar.google.com'],
\ ['ユダヤ教の祝日', 'ja.jewish#holiday@group.v.calendar.google.com'],
\ ['ロシアの祝日', 'ja.russian#holiday@group.v.calendar.google.com'],
\ ['中国の祝日', 'ja.china#holiday@group.v.calendar.google.com'],
\ ['韓国の祝日', 'ja.south_korea#holiday@group.v.calendar.google.com'],
\ ['南アフリカの祝日', 'ja.sa#holiday@group.v.calendar.google.com'],
\ ['台湾の祝日', 'ja.taiwan#holiday@group.v.calendar.google.com'],
\ ['日本の祝日', 'ja.japanese#holiday@group.v.calendar.google.com'],
\ ['香港(C)の祝日', 'ja.hong_kong_c#holiday@group.v.calendar.google.com'],
\ ['香港の祝日', 'ja.hong_kong#holiday@group.v.calendar.google.com'],
\ ]
function! s:urlescape(s)
return substitute(a:s, '[#@]', '\=printf("%%%02x", char2nr(submatch(0)))', 'g')
endfunction
function! s:fetch(id)
let res = http#get(printf('http://www.google.com/calendar/feeds/%s/public/full?alt=json&max-results=99999', s:urlescape(a:id)))
return json#decode(res.content)
endfunction
function! s:order_by_startTime(a, b)
let a = a:a['gd$when'][0]['startTime']
let b = a:b['gd$when'][0]['startTime']
return a < b ? -1 : a > b ? 1 : 0
endfunction
function! s:main()
for [name, id] in s:calendar_list
echo name
let feed = s:fetch(id)
for entry in sort(feed['feed']['entry'], 's:order_by_startTime')
echo [entry['gd$when'][0]['startTime'], entry['title']['$t']]
endfor
endfor
endfunction
try
call s:main()
endtry
Australian Holidays,en.australian#holiday@group.v.calendar.google.com
Austrian Holidays,en.austrian#holiday@group.v.calendar.google.com
Brazilian Holidays,en.brazilian#holiday@group.v.calendar.google.com
Canadian Holidays,en.canadian#holiday@group.v.calendar.google.com
China Holidays,en.china#holiday@group.v.calendar.google.com
Christian Holidays,en.christian#holiday@group.v.calendar.google.com
Danish Holidays,en.danish#holiday@group.v.calendar.google.com
Dutch Holidays,en.dutch#holiday@group.v.calendar.google.com
Finnish Holidays,en.finnish#holiday@group.v.calendar.google.com
French Holidays,en.french#holiday@group.v.calendar.google.com
German Holidays,en.german#holiday@group.v.calendar.google.com
Greek Holidays,en.greek#holiday@group.v.calendar.google.com
Hong Kong (C) Holidays,en.hong_kong_c#holiday@group.v.calendar.google.com
Hong Kong Holidays,en.hong_kong#holiday@group.v.calendar.google.com
Indian Holidays,en.indian#holiday@group.v.calendar.google.com
Indonesian Holidays,en.indonesian#holiday@group.v.calendar.google.com
Iranian Holidays,en.iranian#holiday@group.v.calendar.google.com
Irish Holidays,en.irish#holiday@group.v.calendar.google.com
Islamic Holidays,en.islamic#holiday@group.v.calendar.google.com
Italian Holidays,en.italian#holiday@group.v.calendar.google.com
Japanese Holidays,en.japanese#holiday@group.v.calendar.google.com
Jewish Holidays,en.jewish#holiday@group.v.calendar.google.com
Malaysian Holidays,en.malaysia#holiday@group.v.calendar.google.com
Mexican Holidays,en.mexican#holiday@group.v.calendar.google.com
New Zealand Holidays,en.new_zealand#holiday@group.v.calendar.google.com
Norwegian Holidays,en.norwegian#holiday@group.v.calendar.google.com
Philippines Holidays,en.philippines#holiday@group.v.calendar.google.com
Polish Holidays,en.polish#holiday@group.v.calendar.google.com
Portuguese Holidays,en.portuguese#holiday@group.v.calendar.google.com
Russian Holidays,en.russian#holiday@group.v.calendar.google.com
Singapore Holidays,en.singapore#holiday@group.v.calendar.google.com
South Africa Holidays,en.sa#holiday@group.v.calendar.google.com
South Korean Holidays,en.south_korea#holiday@group.v.calendar.google.com
Spain Holidays,en.spain#holiday@group.v.calendar.google.com
Swedish Holidays,en.swedish#holiday@group.v.calendar.google.com
Taiwan Holidays,en.taiwan#holiday@group.v.calendar.google.com
Thai Holidays,en.thai#holiday@group.v.calendar.google.com
UK Holidays,en.uk#holiday@group.v.calendar.google.com
Ukraine Holidays,en.ukrainian#holiday@group.v.calendar.google.com
US Holidays,en.usa#holiday@group.v.calendar.google.com
Vietnamese Holidays,en.vietnamese#holiday@group.v.calendar.google.com
アイルランドの祝日,ja.irish#holiday@group.v.calendar.google.com
アメリカの祝日,ja.usa#holiday@group.v.calendar.google.com
イギリスの祝日,ja.uk#holiday@group.v.calendar.google.com
イスラム教の祝日,ja.islamic#holiday@group.v.calendar.google.com
イタリアの祝日,ja.italian#holiday@group.v.calendar.google.com
インドの祝日,ja.indian#holiday@group.v.calendar.google.com
インドネシアの祝日,ja.indonesian#holiday@group.v.calendar.google.com
オランダの祝日,ja.dutch#holiday@group.v.calendar.google.com
オーストラリアの祝日,ja.australian#holiday@group.v.calendar.google.com
オーストリアの祝日,ja.austrian#holiday@group.v.calendar.google.com
カナダの祝日,ja.canadian#holiday@group.v.calendar.google.com
キリスト教の祝日,ja.christian#holiday@group.v.calendar.google.com
ギリシャの祝日,ja.greek#holiday@group.v.calendar.google.com
シンガポールの祝日,ja.singapore#holiday@group.v.calendar.google.com
スウェーデンの祝日,ja.swedish#holiday@group.v.calendar.google.com
スペインの祝日,ja.spain#holiday@group.v.calendar.google.com
タイの祝日,ja.thai#holiday@group.v.calendar.google.com
デンマークの祝日,ja.danish#holiday@group.v.calendar.google.com
ドイツの祝日,ja.german#holiday@group.v.calendar.google.com
ニュージーランドの祝日,ja.new_zealand#holiday@group.v.calendar.google.com
ノルウェイの祝日,ja.norwegian#holiday@group.v.calendar.google.com
フィリピンの祝日,ja.philippines#holiday@group.v.calendar.google.com
フィンランドの祝日,ja.finnish#holiday@group.v.calendar.google.com
フランスの祝日,ja.french#holiday@group.v.calendar.google.com
ブラジルの祝日,ja.brazilian#holiday@group.v.calendar.google.com
ベトナムの祝日,ja.vietnamese#holiday@group.v.calendar.google.com
ポルトガルの祝日,ja.portuguese#holiday@group.v.calendar.google.com
ポーランドの祝日,ja.polish#holiday@group.v.calendar.google.com
マレーシアの祝日,ja.malaysia#holiday@group.v.calendar.google.com
メキシコの祝日,ja.mexican#holiday@group.v.calendar.google.com
ユダヤ教の祝日,ja.jewish#holiday@group.v.calendar.google.com
ロシアの祝日,ja.russian#holiday@group.v.calendar.google.com
中国の祝日,ja.china#holiday@group.v.calendar.google.com
韓国の祝日,ja.south_korea#holiday@group.v.calendar.google.com
南アフリカの祝日,ja.sa#holiday@group.v.calendar.google.com
台湾の祝日,ja.taiwan#holiday@group.v.calendar.google.com
日本の祝日,ja.japanese#holiday@group.v.calendar.google.com
香港(C)の祝日,ja.hong_kong_c#holiday@group.v.calendar.google.com
香港の祝日,ja.hong_kong#holiday@group.v.calendar.google.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment