module LiveJournal
Constants
- DEFAULT_SERVER
- HAVE_XML_PARSER
- VERSION
Public Class Methods
coerce_gmt(time)
click to toggle source
LiveJournal
times have no time zone, as they are for display only: “I wrote this post at midnight”. However, it's convenient to represent times with a Ruby time object. But when time zones get involved, everything gets confused; we'd like to store a Unix time in the database and those only make sense as GMT. To reduce confusion, then, we imagine all LiveJournal
times are in GMT. This function takes a time in any time zone and just switches the timezone to GMT. That is, coerce_gmt
of 11:12pm PST is 11:12 pm GMT. The entry time-setting functions require this GMT part to verify you're thinking carefully about time when you use Entry#time
. If I want an entry that has a time that corresponds to what I feel is “now”, I'd use
LiveJournal::coerce_gmt Time.now
# File lib/livejournal/entry.rb, line 40 def self.coerce_gmt time expanded = time.to_a expanded[8] = false # dst flag expanded[9] = 'GMT' return Time.gm(*expanded) end