-
Notifications
You must be signed in to change notification settings - Fork 182
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
Blog date check not taking into account frontmatter offset #143
Comments
Update... The generator doesn't take into account the differences either, so at 00:37 on the 23rd (gone midnight in Italy) but while it's still 23:37 on the 22nd in London, creating an article produces a file with the incorrect name:
Happy to try and do some work on this one, but unsure of the correct behaviour. Would it make sense that the file name and frontmatter reflect the timezone they were created in, but, if a different timezone is set in the blog, the page is proxied to the new date? |
It should probably use the timezone set by the blog configuration. |
I checked, and we have tests for this exact case. Could you please try with the latest |
When use %Z for date formatting, it does not always the same time when parsing that again. That is why it complain 'filename doesn't match the date in its frontmatter', see middleman#143 ``` >> Time.zone = 'Beijing' => "Beijing" >> t = Time.zone.now => Wed, 23 Apr 2014 14:08:22 CST +08:00 >> t.strftime('%F %R %Z') => "2014-04-23 14:08 CST" >> Time.zone.parse "2014-04-23 14:08 CST" => Thu, 24 Apr 2014 04:08:00 CST +08:00 >> ``` We can list all the TimeZone abbreviations below, there are some abbreviations conflicts in different time zones. It shouldn't be used to parse from. ## Time zone abbreviation conflicts ``` CST (GMT+08:00) Beijing", CST (GMT+08:00) Chongqing", CST (GMT+08:00) Taipei", CST (GMT+08:00) Urumqi", CST (GMT+09:30) Adelaide", CST (GMT+09:30) Darwin", CST (GMT-06:00) Central America", CST (GMT-06:00) Saskatchewan", WST (GMT+08:00) Perth", WST (GMT+13:00) Samoa", ``` ## To get all time zone abbreviation list ``` ActiveSupport::TimeZone.all.map{|tz| Time.now.in_time_zone(tz).strftime("%Z") + " " + tz.to_s} [ [ 0] "SST (GMT-11:00) American Samoa", [ 1] "SST (GMT-11:00) International Date Line West", [ 2] "SST (GMT-11:00) Midway Island", [ 3] "HST (GMT-10:00) Hawaii", [ 4] "AKDT (GMT-09:00) Alaska", [ 5] "PDT (GMT-08:00) Pacific Time (US & Canada)", [ 6] "PDT (GMT-08:00) Tijuana", [ 7] "MST (GMT-07:00) Arizona", [ 8] "MDT (GMT-07:00) Chihuahua", [ 9] "MDT (GMT-07:00) Mazatlan", [ 10] "MDT (GMT-07:00) Mountain Time (US & Canada)", [ 11] "CST (GMT-06:00) Central America", [ 12] "CDT (GMT-06:00) Central Time (US & Canada)", [ 13] "CDT (GMT-06:00) Guadalajara", [ 14] "CDT (GMT-06:00) Mexico City", [ 15] "CDT (GMT-06:00) Monterrey", [ 16] "CST (GMT-06:00) Saskatchewan", [ 17] "COT (GMT-05:00) Bogota", [ 18] "EDT (GMT-05:00) Eastern Time (US & Canada)", [ 19] "EDT (GMT-05:00) Indiana (East)", [ 20] "PET (GMT-05:00) Lima", [ 21] "PET (GMT-05:00) Quito", [ 22] "VET (GMT-04:30) Caracas", [ 23] "ADT (GMT-04:00) Atlantic Time (Canada)", [ 24] "GYT (GMT-04:00) Georgetown", [ 25] "BOT (GMT-04:00) La Paz", [ 26] "CLST (GMT-04:00) Santiago", [ 27] "NDT (GMT-03:30) Newfoundland", [ 28] "BRT (GMT-03:00) Brasilia", [ 29] "ART (GMT-03:00) Buenos Aires", [ 30] "WGST (GMT-03:00) Greenland", [ 31] "UYT (GMT-03:00) Montevideo", [ 32] "GST (GMT-02:00) Mid-Atlantic", [ 33] "AZOST (GMT-01:00) Azores", [ 34] "CVT (GMT-01:00) Cape Verde Is.", [ 35] "WEST (GMT+00:00) Casablanca", [ 36] "IST (GMT+00:00) Dublin", [ 37] "BST (GMT+00:00) Edinburgh", [ 38] "WEST (GMT+00:00) Lisbon", [ 39] "BST (GMT+00:00) London", [ 40] "GMT (GMT+00:00) Monrovia", [ 41] "UTC (GMT+00:00) UTC", [ 42] "CEST (GMT+01:00) Amsterdam", [ 43] "CEST (GMT+01:00) Belgrade", [ 44] "CEST (GMT+01:00) Berlin", [ 45] "CEST (GMT+01:00) Bern", [ 46] "CEST (GMT+01:00) Bratislava", [ 47] "CEST (GMT+01:00) Brussels", [ 48] "CEST (GMT+01:00) Budapest", [ 49] "CEST (GMT+01:00) Copenhagen", [ 50] "CEST (GMT+01:00) Ljubljana", [ 51] "CEST (GMT+01:00) Madrid", [ 52] "CEST (GMT+01:00) Paris", [ 53] "CEST (GMT+01:00) Prague", [ 54] "CEST (GMT+01:00) Rome", [ 55] "CEST (GMT+01:00) Sarajevo", [ 56] "CEST (GMT+01:00) Skopje", [ 57] "CEST (GMT+01:00) Stockholm", [ 58] "CEST (GMT+01:00) Vienna", [ 59] "CEST (GMT+01:00) Warsaw", [ 60] "CET (GMT+01:00) West Central Africa", [ 61] "CEST (GMT+01:00) Zagreb", [ 62] "EEST (GMT+02:00) Athens", [ 63] "EEST (GMT+02:00) Bucharest", [ 64] "EET (GMT+02:00) Cairo", [ 65] "CAT (GMT+02:00) Harare", [ 66] "EEST (GMT+02:00) Helsinki", [ 67] "EEST (GMT+02:00) Istanbul", [ 68] "IDT (GMT+02:00) Jerusalem", [ 69] "EEST (GMT+02:00) Kyiv", [ 70] "SAST (GMT+02:00) Pretoria", [ 71] "EEST (GMT+02:00) Riga", [ 72] "EEST (GMT+02:00) Sofia", [ 73] "EEST (GMT+02:00) Tallinn", [ 74] "EEST (GMT+02:00) Vilnius", [ 75] "AST (GMT+03:00) Baghdad", [ 76] "AST (GMT+03:00) Kuwait", [ 77] "FET (GMT+03:00) Minsk", [ 78] "EAT (GMT+03:00) Nairobi", [ 79] "AST (GMT+03:00) Riyadh", [ 80] "IRDT (GMT+03:30) Tehran", [ 81] "GST (GMT+04:00) Abu Dhabi", [ 82] "AZST (GMT+04:00) Baku", [ 83] "MSK (GMT+04:00) Moscow", [ 84] "GST (GMT+04:00) Muscat", [ 85] "MSK (GMT+04:00) St. Petersburg", [ 86] "GET (GMT+04:00) Tbilisi", [ 87] "MSK (GMT+04:00) Volgograd", [ 88] "AMT (GMT+04:00) Yerevan", [ 89] "AFT (GMT+04:30) Kabul", [ 90] "PKT (GMT+05:00) Islamabad", [ 91] "PKT (GMT+05:00) Karachi", [ 92] "UZT (GMT+05:00) Tashkent", [ 93] "IST (GMT+05:30) Chennai", [ 94] "IST (GMT+05:30) Kolkata", [ 95] "IST (GMT+05:30) Mumbai", [ 96] "IST (GMT+05:30) New Delhi", [ 97] "IST (GMT+05:30) Sri Jayawardenepura", [ 98] "NPT (GMT+05:45) Kathmandu", [ 99] "ALMT (GMT+06:00) Almaty", [100] "BDT (GMT+06:00) Astana", [101] "BDT (GMT+06:00) Dhaka", [102] "YEKT (GMT+06:00) Ekaterinburg", [103] "MMT (GMT+06:30) Rangoon", [104] "ICT (GMT+07:00) Bangkok", [105] "ICT (GMT+07:00) Hanoi", [106] "WIB (GMT+07:00) Jakarta", [107] "NOVT (GMT+07:00) Novosibirsk", [108] "CST (GMT+08:00) Beijing", [109] "CST (GMT+08:00) Chongqing", [110] "HKT (GMT+08:00) Hong Kong", [111] "KRAT (GMT+08:00) Krasnoyarsk", [112] "MYT (GMT+08:00) Kuala Lumpur", [113] "WST (GMT+08:00) Perth", [114] "SGT (GMT+08:00) Singapore", [115] "CST (GMT+08:00) Taipei", [116] "ULAT (GMT+08:00) Ulaanbaatar", [117] "CST (GMT+08:00) Urumqi", [118] "IRKT (GMT+09:00) Irkutsk", [119] "JST (GMT+09:00) Osaka", [120] "JST (GMT+09:00) Sapporo", [121] "KST (GMT+09:00) Seoul", [122] "JST (GMT+09:00) Tokyo", [123] "CST (GMT+09:30) Adelaide", [124] "CST (GMT+09:30) Darwin", [125] "EST (GMT+10:00) Brisbane", [126] "EST (GMT+10:00) Canberra", [127] "ChST (GMT+10:00) Guam", [128] "EST (GMT+10:00) Hobart", [129] "EST (GMT+10:00) Melbourne", [130] "PGT (GMT+10:00) Port Moresby", [131] "EST (GMT+10:00) Sydney", [132] "YAKT (GMT+10:00) Yakutsk", [133] "NCT (GMT+11:00) New Caledonia", [134] "SBT (GMT+11:00) Solomon Is.", [135] "VLAT (GMT+11:00) Vladivostok", [136] "NZST (GMT+12:00) Auckland", [137] "FJT (GMT+12:00) Fiji", [138] "PETT (GMT+12:00) Kamchatka", [139] "MAGT (GMT+12:00) Magadan", [140] "MHT (GMT+12:00) Marshall Is.", [141] "NZST (GMT+12:00) Wellington", [142] "CHAST (GMT+12:45) Chatham Is.", [143] "TOT (GMT+13:00) Nuku'alofa", [144] "WST (GMT+13:00) Samoa", [145] "TKT (GMT+13:00) Tokelau Is." ] ```
I had this issue when setting Time.zone = "Taipei". So I comment Time.zone, and everything works. ruby 2.2.1p85 / middleman (3.3.12) / middleman-blog (3.5.3) |
@onenight This is because in the latest version, wongyouth@ab91e6d is reverted. |
You can use a custom template to solve this problem. blog.new_article_template = File.expand_path '../your_template.tt', __FILE |
I'm still getting problems with this. Currently running these versions: |
For reference I always set my Timezone to
Which is the correct way I believe Seems as though their are a hierarchy of issues:
The feature is here : https://github.com/middleman/middleman-blog/blob/master/features/filename_date.feature If you can expand on this then that would be great, can you provide a Repo with this please |
As of https://github.com/middleman/middleman/pull/1293/files middleman splits the notion of `:mode` and `:config`. This PR updates middleman-blog to also handle this distinction. This allows generation of blogposts using config for a particular environment using the `--environment` flag. e.g: `middleman article 'Awesome new post' --environment blog would look for config within the `configure :blog do ...` block. The main gotcha I see is that this requires `Time.zone` to be set in config.rb also. I wonder though if that is related to one of the various other date-related issues: middleman#238, middleman#191, middleman#143
With
config.rb
settingTime.zone = 'London'
and the file2010-05-30-and-now-for-something-completely-different.html.erb
containing:middleman (3.0.14) / middleman-blog (3.1.1) crashes with:
I'm currently on holiday in Italy, so my computer's time zone is Rome (GMT+01:00), which due to daylight savings is 2 hours ahead of UTC. So, 5pm here is 4pm in London and 3pm in UTC.
Is it correct that the file naming has to reflect what the rendered time will eventually be?
The text was updated successfully, but these errors were encountered: