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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
$: << "../lib/"
require 'th_mauve'
require 'mauve/mauve_time'
require 'pp'
class TestMauveTime < Mauve::UnitTest
def test_in_x_hours
#
# 5:44pm on a Friday
#
t = Time.local(2011,6,3,17,44,32)
#
# Working hours..
#
hour_0 = Time.local(2011,6,6,9,30,0)
hour_1 = Time.local(2011,6,6,10,30,0)
assert_equal(hour_1, t.in_x_hours(1,"working"))
assert_equal(hour_0, t.in_x_hours(0,"working"))
#
# 4.45pm on a Friday
#
t = Time.local(2011,6,3,16,45,32)
#
# Working hours..
#
hour_0 = Time.local(2011,6,3,16,45,32)
hour_1 = Time.local(2011,6,6,9,45,32)
assert_equal(hour_1, t.in_x_hours(1,"working"))
assert_equal(hour_0, t.in_x_hours(0,"working"))
end
def test_bank_holiday?
x = Time.now
assert(!x.bank_holiday?)
x.bank_holidays << Date.new(x.year, x.month, x.day)
assert(x.bank_holiday?)
end
def test_dead_zone?
x = Time.local(2012,5,2,4,30,0)
assert(x.dead_zone?)
x = Time.local(2012,5,2,9,30,0)
assert(!x.dead_zone?)
end
def test_daytime_hours
x = Time.local(2012,5,2,4,30,0)
assert(!x.daytime_hours?)
x = Time.local(2012,5,2,9,30,0)
assert(x.daytime_hours?)
end
end
|