chronos 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +27 -0
- data/HISTORY.rdoc +4 -0
- data/LICENSE.txt +52 -0
- data/MANIFEST.txt +51 -0
- data/NOTES.rdoc +85 -0
- data/README.rdoc +125 -0
- data/Rakefile +34 -0
- data/TODO.rdoc +63 -0
- data/bench/completebench.rb +24 -0
- data/ext/cchronos/extconf.rb +5 -0
- data/ext/chronos_core/extconf.rb +5 -0
- data/lib/chronos.rb +208 -0
- data/lib/chronos/calendar.rb +16 -0
- data/lib/chronos/calendar/gregorian.rb +94 -0
- data/lib/chronos/data/zones.tab +424 -0
- data/lib/chronos/datetime.rb +299 -0
- data/lib/chronos/datetime/gregorian.rb +698 -0
- data/lib/chronos/duration.rb +141 -0
- data/lib/chronos/duration/gregorian.rb +261 -0
- data/lib/chronos/durationtotext.rb +42 -0
- data/lib/chronos/exceptions.rb +16 -0
- data/lib/chronos/gregorian.rb +27 -0
- data/lib/chronos/interval.rb +132 -0
- data/lib/chronos/interval/gregorian.rb +80 -0
- data/lib/chronos/locale/parsers/de_CH.rb +50 -0
- data/lib/chronos/locale/parsers/en_US.rb +1 -0
- data/lib/chronos/locale/parsers/generic.rb +21 -0
- data/lib/chronos/locale/strings/de_DE.yaml +76 -0
- data/lib/chronos/locale/strings/en_US.yaml +76 -0
- data/lib/chronos/minimalistic.rb +37 -0
- data/lib/chronos/numeric/gregorian.rb +100 -0
- data/lib/chronos/ruby.rb +6 -0
- data/lib/chronos/version.rb +21 -0
- data/lib/chronos/zone.rb +212 -0
- data/rake/initialize.rb +116 -0
- data/rake/lib/assesscode.rb +59 -0
- data/rake/lib/bonesplitter.rb +245 -0
- data/rake/lib/projectclass.rb +69 -0
- data/rake/tasks/copyright.rake +24 -0
- data/rake/tasks/gem.rake +119 -0
- data/rake/tasks/git.rake +40 -0
- data/rake/tasks/loc.rake +33 -0
- data/rake/tasks/manifest.rake +63 -0
- data/rake/tasks/meta.rake +16 -0
- data/rake/tasks/notes.rake +36 -0
- data/rake/tasks/post_load.rake +18 -0
- data/rake/tasks/rdoc.rake +73 -0
- data/rake/tasks/rubyforge.rake +67 -0
- data/rake/tasks/spec.rake +55 -0
- data/spec/bacon_helper.rb +43 -0
- data/spec/lib/chronos/datetime/gregorian_spec.rb +314 -0
- data/spec/lib/chronos/datetime_spec.rb +219 -0
- data/spec/lib/chronos_spec.rb +91 -0
- metadata +111 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
unless $LOADED_FEATURES.include?('bacon_helper.rb')
|
2
|
+
load(File.expand_path("#{__FILE__}/../../bacon_helper.rb"))
|
3
|
+
$LOADED_FEATURES << 'bacon_helper.rb'
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'time'
|
7
|
+
require 'date'
|
8
|
+
require 'chronos'
|
9
|
+
|
10
|
+
describe 'Chronos should provide localized strings' do
|
11
|
+
before do
|
12
|
+
Chronos.strings.keys.should.not.be.empty
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'for monthnames' do
|
16
|
+
Chronos.strings.keys.each { |language|
|
17
|
+
12.times { |i|
|
18
|
+
Chronos.string(language, :monthname, i).should.be.kind_of String
|
19
|
+
}
|
20
|
+
}
|
21
|
+
# take 4 samples to verify that they aren't arbitrary strings
|
22
|
+
Chronos.string('en_US', :monthname, 0).should.equal "january"
|
23
|
+
Chronos.string('en_US', :monthname, 3).should.equal "april"
|
24
|
+
Chronos.string('de_DE', :monthname, 0).should.equal "Januar"
|
25
|
+
Chronos.string('de_DE', :monthname, 3).should.equal "April"
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'for abbreviated monthnames' do
|
29
|
+
Chronos.strings.keys.each { |language|
|
30
|
+
12.times { |i|
|
31
|
+
Chronos.string(language, :monthnameshort, i).should.be.kind_of String
|
32
|
+
}
|
33
|
+
}
|
34
|
+
# take 4 samples to verify that they aren't arbitrary strings
|
35
|
+
Chronos.string('en_US', :monthnameshort, 0).should.equal "jan"
|
36
|
+
Chronos.string('en_US', :monthnameshort, 3).should.equal "apr"
|
37
|
+
Chronos.string('de_DE', :monthnameshort, 0).should.equal "Jan"
|
38
|
+
Chronos.string('de_DE', :monthnameshort, 3).should.equal "Apr"
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'for daynames' do
|
42
|
+
Chronos.strings.keys.each { |language|
|
43
|
+
7.times { |i|
|
44
|
+
Chronos.string(language, :dayname, i).should.be.kind_of String
|
45
|
+
}
|
46
|
+
}
|
47
|
+
# take 4 samples to verify that they aren't arbitrary strings
|
48
|
+
Chronos.string('en_US', :dayname, 0).should.equal "monday"
|
49
|
+
Chronos.string('en_US', :dayname, 3).should.equal "thursday"
|
50
|
+
Chronos.string('de_DE', :dayname, 0).should.equal "Montag"
|
51
|
+
Chronos.string('de_DE', :dayname, 3).should.equal "Donnerstag"
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'for abbreviated daynames' do
|
55
|
+
Chronos.strings.keys.each { |language|
|
56
|
+
7.times { |i|
|
57
|
+
Chronos.string(language, :daynameshort, i).should.be.kind_of String
|
58
|
+
}
|
59
|
+
}
|
60
|
+
# take 4 samples to verify that they aren't arbitrary strings
|
61
|
+
Chronos.string('en_US', :daynameshort, 0).should.equal "mo"
|
62
|
+
Chronos.string('en_US', :daynameshort, 3).should.equal "th"
|
63
|
+
Chronos.string('de_DE', :daynameshort, 0).should.equal "Mo"
|
64
|
+
Chronos.string('de_DE', :daynameshort, 3).should.equal "Do"
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'for the units' do
|
68
|
+
Chronos.strings.keys.each { |language|
|
69
|
+
[:picosecond, :nanosecond, :microsecond, :millisecond, :second, :minute, :hour, :day, :week, :month, :year].each { |unit|
|
70
|
+
3.times { |i|
|
71
|
+
Chronos.string(language, unit, i).should.be.kind_of String
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
# take 4 samples to verify that they aren't arbitrary strings
|
76
|
+
Chronos.string('en_US', :day, 1).should.equal "day"
|
77
|
+
Chronos.string('en_US', :month, 3).should.equal "months"
|
78
|
+
Chronos.string('de_DE', :day, 1).should.equal "Tag"
|
79
|
+
Chronos.string('de_DE', :month, 3).should.equal "Monate"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "Chronos should know timezones" do
|
84
|
+
it "should return a default timezone with no further data given" do
|
85
|
+
Chronos.timezone.should.be.kind_of Chronos::Zone
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should raise if a specified timezone can't be normalized" do
|
89
|
+
proc { Chronos.timezone('notmakingafrigginsense') }.should.raise ArgumentError
|
90
|
+
end
|
91
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chronos
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stefan Rusterholz
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-08-24 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: (none yet)
|
17
|
+
email: apeiros@gmx.net
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions:
|
21
|
+
- ext/cchronos/extconf.rb
|
22
|
+
- ext/chronos_core/extconf.rb
|
23
|
+
extra_rdoc_files: []
|
24
|
+
|
25
|
+
files:
|
26
|
+
- CHANGELOG.rdoc
|
27
|
+
- HISTORY.rdoc
|
28
|
+
- LICENSE.txt
|
29
|
+
- MANIFEST.txt
|
30
|
+
- NOTES.rdoc
|
31
|
+
- README.rdoc
|
32
|
+
- Rakefile
|
33
|
+
- TODO.rdoc
|
34
|
+
- bench/completebench.rb
|
35
|
+
- lib/chronos.rb
|
36
|
+
- lib/chronos/calendar.rb
|
37
|
+
- lib/chronos/calendar/gregorian.rb
|
38
|
+
- lib/chronos/data/zones.tab
|
39
|
+
- lib/chronos/datetime.rb
|
40
|
+
- lib/chronos/datetime/gregorian.rb
|
41
|
+
- lib/chronos/duration.rb
|
42
|
+
- lib/chronos/duration/gregorian.rb
|
43
|
+
- lib/chronos/durationtotext.rb
|
44
|
+
- lib/chronos/exceptions.rb
|
45
|
+
- lib/chronos/gregorian.rb
|
46
|
+
- lib/chronos/interval.rb
|
47
|
+
- lib/chronos/interval/gregorian.rb
|
48
|
+
- lib/chronos/locale/parsers/de_CH.rb
|
49
|
+
- lib/chronos/locale/parsers/en_US.rb
|
50
|
+
- lib/chronos/locale/parsers/generic.rb
|
51
|
+
- lib/chronos/locale/strings/de_DE.yaml
|
52
|
+
- lib/chronos/locale/strings/en_US.yaml
|
53
|
+
- lib/chronos/minimalistic.rb
|
54
|
+
- lib/chronos/numeric/gregorian.rb
|
55
|
+
- lib/chronos/ruby.rb
|
56
|
+
- lib/chronos/version.rb
|
57
|
+
- lib/chronos/zone.rb
|
58
|
+
- rake/initialize.rb
|
59
|
+
- rake/lib/assesscode.rb
|
60
|
+
- rake/lib/bonesplitter.rb
|
61
|
+
- rake/lib/projectclass.rb
|
62
|
+
- rake/tasks/copyright.rake
|
63
|
+
- rake/tasks/gem.rake
|
64
|
+
- rake/tasks/git.rake
|
65
|
+
- rake/tasks/loc.rake
|
66
|
+
- rake/tasks/manifest.rake
|
67
|
+
- rake/tasks/meta.rake
|
68
|
+
- rake/tasks/notes.rake
|
69
|
+
- rake/tasks/post_load.rake
|
70
|
+
- rake/tasks/rdoc.rake
|
71
|
+
- rake/tasks/rubyforge.rake
|
72
|
+
- rake/tasks/spec.rake
|
73
|
+
- spec/bacon_helper.rb
|
74
|
+
- spec/lib/chronos/datetime/gregorian_spec.rb
|
75
|
+
- spec/lib/chronos/datetime_spec.rb
|
76
|
+
- spec/lib/chronos_spec.rb
|
77
|
+
has_rdoc: true
|
78
|
+
homepage: http://chronos.rubyforge.org/
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options:
|
81
|
+
- --inline-source
|
82
|
+
- --line-numbers
|
83
|
+
- --charset
|
84
|
+
- utf-8
|
85
|
+
- --tab-width
|
86
|
+
- "2"
|
87
|
+
- -t
|
88
|
+
- chronos-0.1.0 Documentation
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: "0"
|
96
|
+
version:
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: "0"
|
102
|
+
version:
|
103
|
+
requirements: []
|
104
|
+
|
105
|
+
rubyforge_project: chronos
|
106
|
+
rubygems_version: 1.2.0
|
107
|
+
signing_key:
|
108
|
+
specification_version: 2
|
109
|
+
summary: Chronos is a library that lets you easily deal with various kinds of calculations with dates, times, durations and intervals.
|
110
|
+
test_files: []
|
111
|
+
|