maciakl / MarkdownJournal

Plain text journaling with Markdown and Dropbox on the Sinatra platform.
http://markdownjournal.com
46 stars 7 forks source link

Add time offset to config #2

Closed Mitlik closed 11 years ago

Mitlik commented 11 years ago

Time stamps are two hours behind my current location.

maciakl commented 11 years ago

Thanks. This is next on the feature list.

Mitlik commented 11 years ago

I put the following proof of concept together using straight ruby 1.9 before noticing you must be using a gem or rails. But I thought I would offer it up.

cat >/tmp/time_test.rb << EOF

! /bin/ruby

Set timezone to EST because main server is set to PST time

Time.zone = "Eastern Time (US & Canada)"

use_dst = false time_offset=-6 tm = Time.now

puts "DST: #{Time.now.isdst}" puts "Date: " + tm.strftime("%Y%m%d")

if use_dst and tm.isdst then adjusted_offset = time_offset +1 else adjusted_offset = time_offset end str_offset = "#{adjusted_offset.abs}" if adjusted_offset.abs < 10 then str_offset = "0" + str_offset end if adjusted_offset < 0 then str_offset = "-" + str_offset end

puts "Offset: " + str_offset puts "Hello, World! It is " + tm.localtime(str_offset + ":00").strftime("%R")

EOF ruby /tmp/time_test.rb

maciakl commented 11 years ago

Ok, I think this is fixed. Full list of available timezone strings is here: https://github.com/maciakl/MarkdownJournal/wiki/Timezones