File: local.rb

package info (click to toggle)
ruby3.3 3.3.8-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 153,620 kB
  • sloc: ruby: 1,244,308; ansic: 836,474; yacc: 28,074; pascal: 6,748; sh: 3,913; python: 1,719; cpp: 1,158; makefile: 742; asm: 712; javascript: 394; lisp: 97; perl: 62; awk: 36; sed: 23; xml: 4
file content (42 lines) | stat: -rw-r--r-- 1,449 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
describe :time_local, shared: true do
  it "creates a time based on given values, interpreted in the local time zone" do
    with_timezone("PST", -8) do
      Time.send(@method, 2000, "jan", 1, 20, 15, 1).to_a.should ==
        [1, 15, 20, 1, 1, 2000, 6, 1, false, "PST"]
    end
  end

  platform_is_not :windows do
    it "uses the 'CET' timezone with TZ=Europe/Amsterdam in 1970" do
      with_timezone("Europe/Amsterdam") do
        Time.send(@method, 1970, 5, 16).to_a.should ==
          [0, 0, 0, 16, 5, 1970, 6, 136, false, "CET"]
      end
    end
  end
end

describe :time_local_10_arg, shared: true do
  it "creates a time based on given C-style gmtime arguments, interpreted in the local time zone" do
    with_timezone("PST", -8) do
      Time.send(@method, 1, 15, 20, 1, 1, 2000, :ignored, :ignored, :ignored, :ignored).to_a.should ==
        [1, 15, 20, 1, 1, 2000, 6, 1, false, "PST"]
    end
  end

  platform_is_not :windows do
    it "creates the correct time just before dst change" do
      with_timezone("America/New_York") do
        time = Time.send(@method, 0, 30, 1, 30, 10, 2005, 0, 0, true, ENV['TZ'])
        time.utc_offset.should == -4 * 3600
      end
    end

    it "creates the correct time just after dst change" do
      with_timezone("America/New_York") do
        time = Time.send(@method, 0, 30, 1, 30, 10, 2005, 0, 0, false, ENV['TZ'])
        time.utc_offset.should == -5 * 3600
      end
    end
  end
end