timezone_test.rb

Cantin Xu, 03/19/2014 06:51 AM

Download (409 Bytes)

 
1
class A
2
  attr_accessor :time
3
  def initialize
4
    @times = []
5
  end
6

    
7
  def add(time)
8
    @times << time
9
  end
10

    
11
  def zones
12
    @times.map(&:zone)
13
  end
14
end
15

    
16
a = A.new
17
arr = []
18

    
19
100000.times do
20
  a.add Time.new
21
end
22

    
23
a = Marshal.load(Marshal.dump(a))
24

    
25
a.zones.each_with_index do |zone, i|
26
  #p ">>>>>>>>>>>>#{i}<<<<<<<<<<<<<< #{zone}" if zone != Time.now.zone
27
  arr << zone if zone != Time.now.zone
28
end
29

    
30
p arr