Sha256: c93401266b0cab7493d2c2e81ee21479391af4a05ea05df567a7a833cb24a8c7

Contents?: true

Size: 430 Bytes

Versions: 15

Compression:

Stored size: 430 Bytes

Contents

class DateTime
  def to_gm_time
    to_time(new_offset, :gm)
  end

  def to_local_time
    to_time(new_offset(DateTime.now.offset-offset), :local)
  end

  private
  def to_time(dest, method)
    #Convert a fraction of a day to a number of microseconds
    usec = (dest.sec_fraction * 60 * 60 * 24 * (10**6)).to_i
    Time.send(method, dest.year, dest.month, dest.day, dest.hour, dest.min,
              dest.sec, usec)
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
cloudsync-2.4.0 lib/cloudsync/datetime/datetime.rb
cloudsync-2.3.0 lib/cloudsync/datetime/datetime.rb
cloudsync-2.2.1 lib/cloudsync/datetime/datetime.rb
cloudsync-2.2.0 lib/cloudsync/datetime/datetime.rb
cloudsync-2.1.1 lib/cloudsync/datetime/datetime.rb
cloudsync-2.1.0 lib/cloudsync/datetime/datetime.rb
cloudsync-2.0.2 lib/cloudsync/datetime/datetime.rb
cloudsync-2.0.1 lib/cloudsync/datetime/datetime.rb
cloudsync-2.0.0 lib/cloudsync/datetime/datetime.rb
cloudsync-1.0.4 lib/cloudsync/datetime/datetime.rb
cloudsync-1.0.3 lib/cloudsync/datetime/datetime.rb
cloudsync-1.0.2 lib/cloudsync/datetime/datetime.rb
cloudsync-1.0.0 lib/cloudsync/datetime/datetime.rb
cloudsync-0.1.1 lib/cloudsync/datetime/datetime.rb
cloudsync-0.1.0 lib/cloudsync/datetime/datetime.rb