Sha256: b825aa744133b4c6917b4423383d001865f682e6f1ef44dc1df3ad274b2e74b8

Contents?: true

Size: 1.04 KB

Versions: 13

Compression:

Stored size: 1.04 KB

Contents

# encoding: UTF-8

require File.expand_path("./helper", File.dirname(__FILE__))

class Post < Ohm::Model
  include Ohm::Typecast

  attribute :printed_at, Time
end

test "2010-08-07T00:00Z is parsed as 2010-08-07 00:00:00 UTC" do
  post = Post.new(:printed_at => "2010-08-07T00:00Z")
  assert Time.utc(2010, 8, 7).to_s == post.printed_at.utc.to_s

  post.save
  post = Post[post.id]
  assert Time.utc(2010, 8, 7).to_s == post.printed_at.utc.to_s
end

test "2010-08-07 18:29Z is parsed as 2010-08-07 18:29:00 UTC" do
  post = Post.new(:printed_at => "2010-08-07 18:29Z")
  assert Time.utc(2010, 8, 7, 18, 29).to_s == post.printed_at.utc.to_s

  post.save
  post = Post[post.id]
  assert Time.utc(2010, 8, 7, 18, 29).to_s == post.printed_at.utc.to_s
end

test "2010-08-07T18:29:31Z is parsed as 2010-08-07 18:29:31 UTC" do
  post = Post.new(:printed_at => "2010-08-07T18:29:31Z")
  assert Time.utc(2010, 8, 7, 18, 29, 31).to_s == post.printed_at.utc.to_s

  post.save
  post = Post[post.id]
  assert Time.utc(2010, 8, 7, 18, 29, 31).to_s == post.printed_at.utc.to_s
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ohm-contrib-0.1.2 test/typecast_timezone_test.rb
ohm-contrib-0.1.1 test/typecast_timezone_test.rb
ohm-contrib-0.1.0 test/typecast_timezone_test.rb
ohm-contrib-0.0.42 test/typecast_timezone_test.rb
ohm-contrib-0.0.41 test/typecast_timezone_test.rb
ohm-contrib-0.0.40 test/typecast_timezone_test.rb
ohm-contrib-0.0.39 test/typecast_timezone_test.rb
ohm-contrib-0.0.38 test/typecast_timezone_test.rb
ohm-contrib-0.0.37 test/typecast_timezone_test.rb
ohm-contrib-0.0.36 test/typecast_timezone_test.rb
ohm-contrib-0.0.35 test/typecast_timezone_test.rb
ohm-contrib-0.0.34 test/typecast_timezone_test.rb
ohm-contrib-0.0.33 test/typecast_timezone_test.rb