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

Middleman build fails when "Middleman article" is used to create article (Timestamp mismatch) #94

Closed
debajit opened this Issue Jan 14, 2013 · 8 comments

Comments

Projects
None yet
5 participants
@debajit

debajit commented Jan 14, 2013

Steps to Reproduce:
• Create a blog article using "middleman article title"
• Run middleman build

Expected Results:
The build should not fail.

Actual Results:
The build fails.

Notes:
This is because the markdown filename contains only the date, whereas the frontmatter contains the time as well.
date: 2006-06-10 00:00 +00:00

@erikthered

This comment has been minimized.

Show comment
Hide comment
@erikthered

erikthered Jan 15, 2013

You need to set the timezone in your config.rb. For example:

Time.zone = "US/Eastern"

This happens because Middleman assumes UTC by default, which is not the case if you're on Windows or something else using localtime.

erikthered commented Jan 15, 2013

You need to set the timezone in your config.rb. For example:

Time.zone = "US/Eastern"

This happens because Middleman assumes UTC by default, which is not the case if you're on Windows or something else using localtime.

@debajit

This comment has been minimized.

Show comment
Hide comment
@debajit

debajit Jan 15, 2013

In my config.rb, I have:

Time.zone = "America/Los_Angeles"

(I am on OS X Mountain Lion)

debajit commented Jan 15, 2013

In my config.rb, I have:

Time.zone = "America/Los_Angeles"

(I am on OS X Mountain Lion)

@erikthered

This comment has been minimized.

Show comment
Hide comment
@erikthered

erikthered Jan 16, 2013

Well, that was my best guess. Maybe since the offset in your frontmatter is set for UTC (+00:00) it's causing a problem? You could try setting the timezone to UTC or removing the timezone if all of your articles are set for +00:00.

Sorry this is kind of a shot in the dark. Maybe one of the devs can help.

erikthered commented Jan 16, 2013

Well, that was my best guess. Maybe since the offset in your frontmatter is set for UTC (+00:00) it's causing a problem? You could try setting the timezone to UTC or removing the timezone if all of your articles are set for +00:00.

Sorry this is kind of a shot in the dark. Maybe one of the devs can help.

@debajit

This comment has been minimized.

Show comment
Hide comment
@debajit

debajit Jan 16, 2013

Yes, removing the time part of the date-time string is a workaround (so I'm not stuck or anything).
The issue that I wanted to point out here is that "middleman article " for a middleman blog creates a filename with only the date (without the time) but adds a YAML frontmatter with the date and time strings which does not build out of the box.

debajit commented Jan 16, 2013

Yes, removing the time part of the date-time string is a workaround (so I'm not stuck or anything).
The issue that I wanted to point out here is that "middleman article " for a middleman blog creates a filename with only the date (without the time) but adds a YAML frontmatter with the date and time strings which does not build out of the box.

@tdreyno

This comment has been minimized.

Show comment
Hide comment
@tdreyno

tdreyno Jan 16, 2013

Member

Understood.

Member

tdreyno commented Jan 16, 2013

Understood.

@bhollis

This comment has been minimized.

Show comment
Hide comment
@bhollis

bhollis Jan 18, 2013

Member

The timestamp isn't even mandatory - it's just in the template so people know they can include it if they want multiple posts from the same day to sort correctly. We should figure out how to generate that timestamp in the specified time zone...

Member

bhollis commented Jan 18, 2013

The timestamp isn't even mandatory - it's just in the template so people know they can include it if they want multiple posts from the same day to sort correctly. We should figure out how to generate that timestamp in the specified time zone...

@bhollis bhollis closed this in c33bc3e Feb 9, 2013

@bhollis

This comment has been minimized.

Show comment
Hide comment
@bhollis

bhollis Feb 9, 2013

Member

OK, I've fixed it to generate the timestamp in the right time zone.

Member

bhollis commented Feb 9, 2013

OK, I've fixed it to generate the timestamp in the right time zone.

@atmosx

This comment has been minimized.

Show comment
Hide comment
@atmosx

atmosx May 23, 2015

Hello,

I am moving from Octopress to Middleman. I made a quick script to fix the dates and worked fine for me:

require 'fileutils'
require 'time'

files = Dir.glob("*.markdown")
puts "Processing #{files.count} files"
files.each do |f|
  list = []
  list << f
  File.readlines(f).each do |line|
    if line.include?("date: ")
      string = line[6,19]
      string.include?("\n") ? s = string.strip : s = string
      time = Time.parse(string)
      FileUtils.touch f, mtime: time
    end
  end
end
puts "Finished!" 

Best regards

UPDATE: Apparently it works for SOME posts but not for others. I can't tell why though.

atmosx commented May 23, 2015

Hello,

I am moving from Octopress to Middleman. I made a quick script to fix the dates and worked fine for me:

require 'fileutils'
require 'time'

files = Dir.glob("*.markdown")
puts "Processing #{files.count} files"
files.each do |f|
  list = []
  list << f
  File.readlines(f).each do |line|
    if line.include?("date: ")
      string = line[6,19]
      string.include?("\n") ? s = string.strip : s = string
      time = Time.parse(string)
      FileUtils.touch f, mtime: time
    end
  end
end
puts "Finished!" 

Best regards

UPDATE: Apparently it works for SOME posts but not for others. I can't tell why though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment