在哪里可以找到R函数as.POSIXct
的所有合法时间名称列表?
as.POSIXct("1970-01-01",tz="CST")
会生成“CST”(中央标准时间)未知的警告。
答案 0 :(得分:20)
?Sys.timezone
有一些提示,特别是要查看:"R_HOME/share/zoneinfo/zone.tab"
(R_HOME
是安装在其中的目录)。请记住,时区是令人讨厌的,他们的许多细微差别是特定的操作系统(和区域设置?)。
在您的具体情况下,您需要"CST6CDT"
而不是"CST"
。
答案 1 :(得分:19)
时区的东西可以带你 NUTS !!
位于德国,这就是我过去常常设置的tz:
> options(tz="Europe/Berlin")
这样做,我总是想知道为什么R会抛出“未知时区”警告:
> t <- "2011-11-08 09:42:00"
> as.POSIXct(t, tz=getOption("tz"))
[1] "2011-11-08 09:42:00 CET"
Warning messages:
1: In strptime(xx, f <- "%Y-%m-%d %H:%M:%OS", tz = tz) :
unknown timezone 'MET-1MST'
2: In as.POSIXct.POSIXlt(x) : unknown timezone 'MET-1MST'
3: In strptime(x, f, tz = tz) : unknown timezone 'MET-1MST'
4: In as.POSIXct.POSIXlt(as.POSIXlt(x, tz, ...), tz, ...) :
unknown timezone 'MET-1MST'
5: In as.POSIXlt.POSIXct(x, tz) : unknown timezone 'MET-1MST'
有一天,我发现通过options()
设置tz是不够的,因为环境变量TZ
不会受到影响,因此会遇到麻烦:
> Sys.getenv("TZ")
[1] "MET-1MST"
改变这一点应该消除令人讨厌的警告:
> Sys.setenv(TZ="Europe/Berlin")
> Sys.getenv("TZ")
[1] "Europe/Berlin"
> as.POSIXct(t, tz=getOption("tz"))
[1] "2011-11-08 09:42:00 CET"
答案 2 :(得分:8)
大多数R平台使用David Olson编译的时区数据库,其中首选参考是按位置。名字有点过时,但它们会帮助你开始。
查找可用时区的完整列表(在Windows上不起作用):
OlsonNames()
对于运行Windows的人来说OlsonNames()不起作用:See the full list here。
答案 3 :(得分:7)
无法在我的make上的该位置找到它,但在源目录中找到了压缩版本。以下是显示在zones.tab
文件顶层的时区缩写列表:
CET, CST6CDT, Cuba, EET, EST, EST5EDT, Egypt, Eire, Factory, GB, GB-Eire, GMT,
GMT+0, GMT-0, GMT0, Greenwich, HST, Hongkong, Iceland, Iran, Israel, Jamaica, Japan,
Kwajalein, Libya, MET, MST, MST7MDT, NZ, NZ-CHAT, Navajo, PRC, PST8PDT, Poland, Portugal,
ROC, ROK, Singapore, Turkey, UCT, UTC, Universal, W-SU, WET, Zulu
还有包含大陆/国家/地区名称的文件夹,其中包含更多选项,例如上面的America/New_York
示例。:
Africa/ Asia/ Canada/ Indian/
America/ Atlantic/ Chile/ Mexico/
Antarctica/ Australia/ Etc/ Pacific/
Arctic/ Brazil/ Europe/ US/
这可以在/R-2.11.1/src/extra/tzone/zoneinfo.zip
文件中找到。
答案 4 :(得分:0)
TL; DR:为此命令设置tz
选项可以使警告消失
options(tz="Asia/Seoul") # Set to appropriate timezone
现在您的R会话中设置了时区,警告将消失。使用OlsonNames()
查看可以使用的时区的完整列表(或向下滚动以查看下面的完整列表)。
相关信息
如果options("tz")
返回NULL
,则表示当前R会话未设置任何时区:
options("tz")
$tz
NULL
使用options("tz")
查看当前设置的时区选项
options(tz="Asia/Seoul")
options("tz")
$tz
[1] "Asia/Seoul"
这里是时区的完整列表。您可以使用OlsonNames()
命令生成列表。
OlsonNames()
[1] "Africa/Abidjan"
[2] "Africa/Accra"
[3] "Africa/Addis_Ababa"
[4] "Africa/Algiers"
[5] "Africa/Asmara"
[6] "Africa/Asmera"
[7] "Africa/Bamako"
[8] "Africa/Bangui"
[9] "Africa/Banjul"
[10] "Africa/Bissau"
[11] "Africa/Blantyre"
[12] "Africa/Brazzaville"
[13] "Africa/Bujumbura"
[14] "Africa/Cairo"
[15] "Africa/Casablanca"
[16] "Africa/Ceuta"
[17] "Africa/Conakry"
[18] "Africa/Dakar"
[19] "Africa/Dar_es_Salaam"
[20] "Africa/Djibouti"
[21] "Africa/Douala"
[22] "Africa/El_Aaiun"
[23] "Africa/Freetown"
[24] "Africa/Gaborone"
[25] "Africa/Harare"
[26] "Africa/Johannesburg"
[27] "Africa/Juba"
[28] "Africa/Kampala"
[29] "Africa/Khartoum"
[30] "Africa/Kigali"
[31] "Africa/Kinshasa"
[32] "Africa/Lagos"
[33] "Africa/Libreville"
[34] "Africa/Lome"
[35] "Africa/Luanda"
[36] "Africa/Lubumbashi"
[37] "Africa/Lusaka"
[38] "Africa/Malabo"
[39] "Africa/Maputo"
[40] "Africa/Maseru"
[41] "Africa/Mbabane"
[42] "Africa/Mogadishu"
[43] "Africa/Monrovia"
[44] "Africa/Nairobi"
[45] "Africa/Ndjamena"
[46] "Africa/Niamey"
[47] "Africa/Nouakchott"
[48] "Africa/Ouagadougou"
[49] "Africa/Porto-Novo"
[50] "Africa/Sao_Tome"
[51] "Africa/Timbuktu"
[52] "Africa/Tripoli"
[53] "Africa/Tunis"
[54] "Africa/Windhoek"
[55] "America/Adak"
[56] "America/Anchorage"
[57] "America/Anguilla"
[58] "America/Antigua"
[59] "America/Araguaina"
[60] "America/Argentina/Buenos_Aires"
[61] "America/Argentina/Catamarca"
[62] "America/Argentina/ComodRivadavia"
[63] "America/Argentina/Cordoba"
[64] "America/Argentina/Jujuy"
[65] "America/Argentina/La_Rioja"
[66] "America/Argentina/Mendoza"
[67] "America/Argentina/Rio_Gallegos"
[68] "America/Argentina/Salta"
[69] "America/Argentina/San_Juan"
[70] "America/Argentina/San_Luis"
[71] "America/Argentina/Tucuman"
[72] "America/Argentina/Ushuaia"
[73] "America/Aruba"
[74] "America/Asuncion"
[75] "America/Atikokan"
[76] "America/Atka"
[77] "America/Bahia"
[78] "America/Bahia_Banderas"
[79] "America/Barbados"
[80] "America/Belem"
[81] "America/Belize"
[82] "America/Blanc-Sablon"
[83] "America/Boa_Vista"
[84] "America/Bogota"
[85] "America/Boise"
[86] "America/Buenos_Aires"
[87] "America/Cambridge_Bay"
[88] "America/Campo_Grande"
[89] "America/Cancun"
[90] "America/Caracas"
[91] "America/Catamarca"
[92] "America/Cayenne"
[93] "America/Cayman"
[94] "America/Chicago"
[95] "America/Chihuahua"
[96] "America/Coral_Harbour"
[97] "America/Cordoba"
[98] "America/Costa_Rica"
[99] "America/Creston"
[100] "America/Cuiaba"
[101] "America/Curacao"
[102] "America/Danmarkshavn"
[103] "America/Dawson"
[104] "America/Dawson_Creek"
[105] "America/Denver"
[106] "America/Detroit"
[107] "America/Dominica"
[108] "America/Edmonton"
[109] "America/Eirunepe"
[110] "America/El_Salvador"
[111] "America/Ensenada"
[112] "America/Fort_Nelson"
[113] "America/Fort_Wayne"
[114] "America/Fortaleza"
[115] "America/Glace_Bay"
[116] "America/Godthab"
[117] "America/Goose_Bay"
[118] "America/Grand_Turk"
[119] "America/Grenada"
[120] "America/Guadeloupe"
[121] "America/Guatemala"
[122] "America/Guayaquil"
[123] "America/Guyana"
[124] "America/Halifax"
[125] "America/Havana"
[126] "America/Hermosillo"
[127] "America/Indiana/Indianapolis"
[128] "America/Indiana/Knox"
[129] "America/Indiana/Marengo"
[130] "America/Indiana/Petersburg"
[131] "America/Indiana/Tell_City"
[132] "America/Indiana/Vevay"
[133] "America/Indiana/Vincennes"
[134] "America/Indiana/Winamac"
[135] "America/Indianapolis"
[136] "America/Inuvik"
[137] "America/Iqaluit"
[138] "America/Jamaica"
[139] "America/Jujuy"
[140] "America/Juneau"
[141] "America/Kentucky/Louisville"
[142] "America/Kentucky/Monticello"
[143] "America/Knox_IN"
[144] "America/Kralendijk"
[145] "America/La_Paz"
[146] "America/Lima"
[147] "America/Los_Angeles"
[148] "America/Louisville"
[149] "America/Lower_Princes"
[150] "America/Maceio"
[151] "America/Managua"
[152] "America/Manaus"
[153] "America/Marigot"
[154] "America/Martinique"
[155] "America/Matamoros"
[156] "America/Mazatlan"
[157] "America/Mendoza"
[158] "America/Menominee"
[159] "America/Merida"
[160] "America/Metlakatla"
[161] "America/Mexico_City"
[162] "America/Miquelon"
[163] "America/Moncton"
[164] "America/Monterrey"
[165] "America/Montevideo"
[166] "America/Montreal"
[167] "America/Montserrat"
[168] "America/Nassau"
[169] "America/New_York"
[170] "America/Nipigon"
[171] "America/Nome"
[172] "America/Noronha"
[173] "America/North_Dakota/Beulah"
[174] "America/North_Dakota/Center"
[175] "America/North_Dakota/New_Salem"
[176] "America/Nuuk"
[177] "America/Ojinaga"
[178] "America/Panama"
[179] "America/Pangnirtung"
[180] "America/Paramaribo"
[181] "America/Phoenix"
[182] "America/Port_of_Spain"
[183] "America/Port-au-Prince"
[184] "America/Porto_Acre"
[185] "America/Porto_Velho"
[186] "America/Puerto_Rico"
[187] "America/Punta_Arenas"
[188] "America/Rainy_River"
[189] "America/Rankin_Inlet"
[190] "America/Recife"
[191] "America/Regina"
[192] "America/Resolute"
[193] "America/Rio_Branco"
[194] "America/Rosario"
[195] "America/Santa_Isabel"
[196] "America/Santarem"
[197] "America/Santiago"
[198] "America/Santo_Domingo"
[199] "America/Sao_Paulo"
[200] "America/Scoresbysund"
[201] "America/Shiprock"
[202] "America/Sitka"
[203] "America/St_Barthelemy"
[204] "America/St_Johns"
[205] "America/St_Kitts"
[206] "America/St_Lucia"
[207] "America/St_Thomas"
[208] "America/St_Vincent"
[209] "America/Swift_Current"
[210] "America/Tegucigalpa"
[211] "America/Thule"
[212] "America/Thunder_Bay"
[213] "America/Tijuana"
[214] "America/Toronto"
[215] "America/Tortola"
[216] "America/Vancouver"
[217] "America/Virgin"
[218] "America/Whitehorse"
[219] "America/Winnipeg"
[220] "America/Yakutat"
[221] "America/Yellowknife"
[222] "Antarctica/Casey"
[223] "Antarctica/Davis"
[224] "Antarctica/DumontDUrville"
[225] "Antarctica/Macquarie"
[226] "Antarctica/Mawson"
[227] "Antarctica/McMurdo"
[228] "Antarctica/Palmer"
[229] "Antarctica/Rothera"
[230] "Antarctica/South_Pole"
[231] "Antarctica/Syowa"
[232] "Antarctica/Troll"
[233] "Antarctica/Vostok"
[234] "Arctic/Longyearbyen"
[235] "Asia/Aden"
[236] "Asia/Almaty"
[237] "Asia/Amman"
[238] "Asia/Anadyr"
[239] "Asia/Aqtau"
[240] "Asia/Aqtobe"
[241] "Asia/Ashgabat"
[242] "Asia/Ashkhabad"
[243] "Asia/Atyrau"
[244] "Asia/Baghdad"
[245] "Asia/Bahrain"
[246] "Asia/Baku"
[247] "Asia/Bangkok"
[248] "Asia/Barnaul"
[249] "Asia/Beirut"
[250] "Asia/Bishkek"
[251] "Asia/Brunei"
[252] "Asia/Calcutta"
[253] "Asia/Chita"
[254] "Asia/Choibalsan"
[255] "Asia/Chongqing"
[256] "Asia/Chungking"
[257] "Asia/Colombo"
[258] "Asia/Dacca"
[259] "Asia/Damascus"
[260] "Asia/Dhaka"
[261] "Asia/Dili"
[262] "Asia/Dubai"
[263] "Asia/Dushanbe"
[264] "Asia/Famagusta"
[265] "Asia/Gaza"
[266] "Asia/Harbin"
[267] "Asia/Hebron"
[268] "Asia/Ho_Chi_Minh"
[269] "Asia/Hong_Kong"
[270] "Asia/Hovd"
[271] "Asia/Irkutsk"
[272] "Asia/Istanbul"
[273] "Asia/Jakarta"
[274] "Asia/Jayapura"
[275] "Asia/Jerusalem"
[276] "Asia/Kabul"
[277] "Asia/Kamchatka"
[278] "Asia/Karachi"
[279] "Asia/Kashgar"
[280] "Asia/Kathmandu"
[281] "Asia/Katmandu"
[282] "Asia/Khandyga"
[283] "Asia/Kolkata"
[284] "Asia/Krasnoyarsk"
[285] "Asia/Kuala_Lumpur"
[286] "Asia/Kuching"
[287] "Asia/Kuwait"
[288] "Asia/Macao"
[289] "Asia/Macau"
[290] "Asia/Magadan"
[291] "Asia/Makassar"
[292] "Asia/Manila"
[293] "Asia/Muscat"
[294] "Asia/Nicosia"
[295] "Asia/Novokuznetsk"
[296] "Asia/Novosibirsk"
[297] "Asia/Omsk"
[298] "Asia/Oral"
[299] "Asia/Phnom_Penh"
[300] "Asia/Pontianak"
[301] "Asia/Pyongyang"
[302] "Asia/Qatar"
[303] "Asia/Qostanay"
[304] "Asia/Qyzylorda"
[305] "Asia/Rangoon"
[306] "Asia/Riyadh"
[307] "Asia/Saigon"
[308] "Asia/Sakhalin"
[309] "Asia/Samarkand"
[310] "Asia/Seoul"
[311] "Asia/Shanghai"
[312] "Asia/Singapore"
[313] "Asia/Srednekolymsk"
[314] "Asia/Taipei"
[315] "Asia/Tashkent"
[316] "Asia/Tbilisi"
[317] "Asia/Tehran"
[318] "Asia/Tel_Aviv"
[319] "Asia/Thimbu"
[320] "Asia/Thimphu"
[321] "Asia/Tokyo"
[322] "Asia/Tomsk"
[323] "Asia/Ujung_Pandang"
[324] "Asia/Ulaanbaatar"
[325] "Asia/Ulan_Bator"
[326] "Asia/Urumqi"
[327] "Asia/Ust-Nera"
[328] "Asia/Vientiane"
[329] "Asia/Vladivostok"
[330] "Asia/Yakutsk"
[331] "Asia/Yangon"
[332] "Asia/Yekaterinburg"
[333] "Asia/Yerevan"
[334] "Atlantic/Azores"
[335] "Atlantic/Bermuda"
[336] "Atlantic/Canary"
[337] "Atlantic/Cape_Verde"
[338] "Atlantic/Faeroe"
[339] "Atlantic/Faroe"
[340] "Atlantic/Jan_Mayen"
[341] "Atlantic/Madeira"
[342] "Atlantic/Reykjavik"
[343] "Atlantic/South_Georgia"
[344] "Atlantic/St_Helena"
[345] "Atlantic/Stanley"
[346] "Australia/ACT"
[347] "Australia/Adelaide"
[348] "Australia/Brisbane"
[349] "Australia/Broken_Hill"
[350] "Australia/Canberra"
[351] "Australia/Currie"
[352] "Australia/Darwin"
[353] "Australia/Eucla"
[354] "Australia/Hobart"
[355] "Australia/LHI"
[356] "Australia/Lindeman"
[357] "Australia/Lord_Howe"
[358] "Australia/Melbourne"
[359] "Australia/North"
[360] "Australia/NSW"
[361] "Australia/Perth"
[362] "Australia/Queensland"
[363] "Australia/South"
[364] "Australia/Sydney"
[365] "Australia/Tasmania"
[366] "Australia/Victoria"
[367] "Australia/West"
[368] "Australia/Yancowinna"
[369] "Brazil/Acre"
[370] "Brazil/DeNoronha"
[371] "Brazil/East"
[372] "Brazil/West"
[373] "Canada/Atlantic"
[374] "Canada/Central"
[375] "Canada/Eastern"
[376] "Canada/Mountain"
[377] "Canada/Newfoundland"
[378] "Canada/Pacific"
[379] "Canada/Saskatchewan"
[380] "Canada/Yukon"
[381] "CET"
[382] "Chile/Continental"
[383] "Chile/EasterIsland"
[384] "CST6CDT"
[385] "Cuba"
[386] "EET"
[387] "Egypt"
[388] "Eire"
[389] "EST"
[390] "EST5EDT"
[391] "Etc/GMT"
[392] "Etc/GMT-0"
[393] "Etc/GMT-1"
[394] "Etc/GMT-10"
[395] "Etc/GMT-11"
[396] "Etc/GMT-12"
[397] "Etc/GMT-13"
[398] "Etc/GMT-14"
[399] "Etc/GMT-2"
[400] "Etc/GMT-3"
[401] "Etc/GMT-4"
[402] "Etc/GMT-5"
[403] "Etc/GMT-6"
[404] "Etc/GMT-7"
[405] "Etc/GMT-8"
[406] "Etc/GMT-9"
[407] "Etc/GMT+0"
[408] "Etc/GMT+1"
[409] "Etc/GMT+10"
[410] "Etc/GMT+11"
[411] "Etc/GMT+12"
[412] "Etc/GMT+2"
[413] "Etc/GMT+3"
[414] "Etc/GMT+4"
[415] "Etc/GMT+5"
[416] "Etc/GMT+6"
[417] "Etc/GMT+7"
[418] "Etc/GMT+8"
[419] "Etc/GMT+9"
[420] "Etc/GMT0"
[421] "Etc/Greenwich"
[422] "Etc/UCT"
[423] "Etc/Universal"
[424] "Etc/UTC"
[425] "Etc/Zulu"
[426] "Europe/Amsterdam"
[427] "Europe/Andorra"
[428] "Europe/Astrakhan"
[429] "Europe/Athens"
[430] "Europe/Belfast"
[431] "Europe/Belgrade"
[432] "Europe/Berlin"
[433] "Europe/Bratislava"
[434] "Europe/Brussels"
[435] "Europe/Bucharest"
[436] "Europe/Budapest"
[437] "Europe/Busingen"
[438] "Europe/Chisinau"
[439] "Europe/Copenhagen"
[440] "Europe/Dublin"
[441] "Europe/Gibraltar"
[442] "Europe/Guernsey"
[443] "Europe/Helsinki"
[444] "Europe/Isle_of_Man"
[445] "Europe/Istanbul"
[446] "Europe/Jersey"
[447] "Europe/Kaliningrad"
[448] "Europe/Kiev"
[449] "Europe/Kirov"
[450] "Europe/Lisbon"
[451] "Europe/Ljubljana"
[452] "Europe/London"
[453] "Europe/Luxembourg"
[454] "Europe/Madrid"
[455] "Europe/Malta"
[456] "Europe/Mariehamn"
[457] "Europe/Minsk"
[458] "Europe/Monaco"
[459] "Europe/Moscow"
[460] "Europe/Nicosia"
[461] "Europe/Oslo"
[462] "Europe/Paris"
[463] "Europe/Podgorica"
[464] "Europe/Prague"
[465] "Europe/Riga"
[466] "Europe/Rome"
[467] "Europe/Samara"
[468] "Europe/San_Marino"
[469] "Europe/Sarajevo"
[470] "Europe/Saratov"
[471] "Europe/Simferopol"
[472] "Europe/Skopje"
[473] "Europe/Sofia"
[474] "Europe/Stockholm"
[475] "Europe/Tallinn"
[476] "Europe/Tirane"
[477] "Europe/Tiraspol"
[478] "Europe/Ulyanovsk"
[479] "Europe/Uzhgorod"
[480] "Europe/Vaduz"
[481] "Europe/Vatican"
[482] "Europe/Vienna"
[483] "Europe/Vilnius"
[484] "Europe/Volgograd"
[485] "Europe/Warsaw"
[486] "Europe/Zagreb"
[487] "Europe/Zaporozhye"
[488] "Europe/Zurich"
[489] "GB"
[490] "GB-Eire"
[491] "GMT"
[492] "GMT-0"
[493] "GMT+0"
[494] "GMT0"
[495] "Greenwich"
[496] "Hongkong"
[497] "HST"
[498] "Iceland"
[499] "Indian/Antananarivo"
[500] "Indian/Chagos"
[501] "Indian/Christmas"
[502] "Indian/Cocos"
[503] "Indian/Comoro"
[504] "Indian/Kerguelen"
[505] "Indian/Mahe"
[506] "Indian/Maldives"
[507] "Indian/Mauritius"
[508] "Indian/Mayotte"
[509] "Indian/Reunion"
[510] "Iran"
[511] "Israel"
[512] "Jamaica"
[513] "Japan"
[514] "Kwajalein"
[515] "Libya"
[516] "MET"
[517] "Mexico/BajaNorte"
[518] "Mexico/BajaSur"
[519] "Mexico/General"
[520] "MST"
[521] "MST7MDT"
[522] "Navajo"
[523] "NZ"
[524] "NZ-CHAT"
[525] "Pacific/Apia"
[526] "Pacific/Auckland"
[527] "Pacific/Bougainville"
[528] "Pacific/Chatham"
[529] "Pacific/Chuuk"
[530] "Pacific/Easter"
[531] "Pacific/Efate"
[532] "Pacific/Enderbury"
[533] "Pacific/Fakaofo"
[534] "Pacific/Fiji"
[535] "Pacific/Funafuti"
[536] "Pacific/Galapagos"
[537] "Pacific/Gambier"
[538] "Pacific/Guadalcanal"
[539] "Pacific/Guam"
[540] "Pacific/Honolulu"
[541] "Pacific/Johnston"
[542] "Pacific/Kiritimati"
[543] "Pacific/Kosrae"
[544] "Pacific/Kwajalein"
[545] "Pacific/Majuro"
[546] "Pacific/Marquesas"
[547] "Pacific/Midway"
[548] "Pacific/Nauru"
[549] "Pacific/Niue"
[550] "Pacific/Norfolk"
[551] "Pacific/Noumea"
[552] "Pacific/Pago_Pago"
[553] "Pacific/Palau"
[554] "Pacific/Pitcairn"
[555] "Pacific/Pohnpei"
[556] "Pacific/Ponape"
[557] "Pacific/Port_Moresby"
[558] "Pacific/Rarotonga"
[559] "Pacific/Saipan"
[560] "Pacific/Samoa"
[561] "Pacific/Tahiti"
[562] "Pacific/Tarawa"
[563] "Pacific/Tongatapu"
[564] "Pacific/Truk"
[565] "Pacific/Wake"
[566] "Pacific/Wallis"
[567] "Pacific/Yap"
[568] "Poland"
[569] "Portugal"
[570] "PRC"
[571] "PST8PDT"
[572] "ROC"
[573] "ROK"
[574] "Singapore"
[575] "Turkey"
[576] "UCT"
[577] "Universal"
[578] "US/Alaska"
[579] "US/Aleutian"
[580] "US/Arizona"
[581] "US/Central"
[582] "US/East-Indiana"
[583] "US/Eastern"
[584] "US/Hawaii"
[585] "US/Indiana-Starke"
[586] "US/Michigan"
[587] "US/Mountain"
[588] "US/Pacific"
[589] "US/Pacific-New"
[590] "US/Samoa"
[591] "UTC"
[592] "W-SU"
[593] "WET"
[594] "Zulu"
attr(,"Version")
[1] "2020a"