roo 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/lib/roo/excelx.rb +36 -4
- data/lib/roo/google.rb +27 -3
- data/lib/roo/version.rb +1 -1
- data/test/test_roo.rb +102 -162
- data/website/index.txt +3 -0
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
+
== 1.2.2 2008-12-??
|
2
|
+
* 2 enhancements
|
3
|
+
* added celltype :datetime in Excelx
|
4
|
+
* added celltype :datetime in Google
|
5
|
+
|
1
6
|
== 1.2.1 2008-11-13
|
2
7
|
* 1 enhancement
|
3
8
|
* added celltype :datetime in Openoffice and Excel
|
9
|
+
|
4
10
|
== 1.2.0 2008-08-24
|
5
11
|
* 3 major enhancements
|
6
12
|
* Excelx: improved the detection of cell type and conversion into roo types
|
data/lib/roo/excelx.rb
CHANGED
@@ -45,6 +45,7 @@ class Excelx < GenericSpreadsheet
|
|
45
45
|
"yyyy\\-mm\\-dd" => :date,
|
46
46
|
'dd/mm/yy' => :date,
|
47
47
|
'hh:mm:ss' => :time,
|
48
|
+
"dd/mm/yy\\ hh:mm" => :datetime,
|
48
49
|
}
|
49
50
|
STANDARD_FORMATS = {
|
50
51
|
0 => 'General',
|
@@ -157,6 +158,12 @@ class Excelx < GenericSpreadsheet
|
|
157
158
|
if celltype(row,col,sheet) == :date
|
158
159
|
yyyy,mm,dd = @cell[sheet][[row,col]].split('-')
|
159
160
|
return Date.new(yyyy.to_i,mm.to_i,dd.to_i)
|
161
|
+
elsif celltype(row,col,sheet) == :datetime
|
162
|
+
date_part,time_part = @cell[sheet][[row,col]].split(' ')
|
163
|
+
yyyy,mm,dd = date_part.split('-')
|
164
|
+
hh,mi,ss = time_part.split(':')
|
165
|
+
return DateTime.civil(yyyy.to_i,mm.to_i,dd.to_i,hh.to_i,mi.to_i,ss.to_i)
|
166
|
+
|
160
167
|
end
|
161
168
|
@cell[sheet][[row,col]]
|
162
169
|
end
|
@@ -209,7 +216,7 @@ class Excelx < GenericSpreadsheet
|
|
209
216
|
# * :formula
|
210
217
|
# * :time
|
211
218
|
# * :datetime
|
212
|
-
def celltype(row,col,sheet=nil)
|
219
|
+
def celltype(row,col,sheet=nil)
|
213
220
|
sheet = @default_sheet unless sheet
|
214
221
|
read_cells(sheet) unless @cells_read[sheet]
|
215
222
|
row,col = normalize(row,col)
|
@@ -309,7 +316,9 @@ def celltype(row,col,sheet=nil)
|
|
309
316
|
when :string
|
310
317
|
@cell[sheet][key] = str_v
|
311
318
|
when :date
|
312
|
-
@cell[sheet][key] = (Date.new(1899,12,30)+v.to_i).strftime("%Y-%m-%d")
|
319
|
+
@cell[sheet][key] = (Date.new(1899,12,30)+v.to_i).strftime("%Y-%m-%d")
|
320
|
+
when :datetime
|
321
|
+
@cell[sheet][key] = (DateTime.new(1899,12,30)+v.to_f).strftime("%Y-%m-%d %H:%M:%S")
|
313
322
|
when :percentage
|
314
323
|
@cell[sheet][key] = v.to_f
|
315
324
|
when :time
|
@@ -383,13 +392,32 @@ def celltype(row,col,sheet=nil)
|
|
383
392
|
end
|
384
393
|
formula = nil
|
385
394
|
row.each_element do |cell|
|
395
|
+
# puts "cell.name: #{cell.name}" if cell.text.include? "22606.5120"
|
396
|
+
# puts "cell.text: #{cell.text}" if cell.text.include? "22606.5120"
|
386
397
|
if cell.name == 'f'
|
387
398
|
formula = cell.text
|
388
399
|
end
|
389
400
|
if cell.name == 'v'
|
390
|
-
|
401
|
+
#puts "tmp_type: #{tmp_type}" if cell.text.include? "22606.5120"
|
402
|
+
#puts cell.name
|
403
|
+
if tmp_type == :time or tmp_type == :datetime #2008-07-26
|
404
|
+
#p cell.text
|
405
|
+
# p cell.text.to_f if cell.text.include? "22606.5120"
|
391
406
|
if cell.text.to_f >= 1.0 # 2008-07-26
|
392
|
-
|
407
|
+
# puts ">= 1.0" if cell.text.include? "22606.5120"
|
408
|
+
# puts "cell.text.to_f: #{cell.text.to_f}" if cell.text.include? "22606.5120"
|
409
|
+
#puts "cell.text.to_f.floor: #{cell.text.to_f.floor}" if cell.text.include? "22606.5120"
|
410
|
+
if (cell.text.to_f - cell.text.to_f.floor).abs > 0.000001 #TODO:
|
411
|
+
# puts "abs ist groesser" if cell.text.include? "22606.5120"
|
412
|
+
# @cell[sheet][key] = DateTime.parse(tr.attributes['date-value'])
|
413
|
+
tmp_type = :datetime
|
414
|
+
|
415
|
+
else
|
416
|
+
#puts ":date"
|
417
|
+
tmp_type = :date # 2008-07-26
|
418
|
+
end
|
419
|
+
else
|
420
|
+
#puts "<1.0"
|
393
421
|
end # 2008-07-26
|
394
422
|
end # 2008-07-26
|
395
423
|
excelx_type = [:numeric_or_formula,format]
|
@@ -404,6 +432,9 @@ def celltype(row,col,sheet=nil)
|
|
404
432
|
elsif tmp_type == :time
|
405
433
|
vt = :time
|
406
434
|
v = cell.text
|
435
|
+
elsif tmp_type == :datetime
|
436
|
+
vt = :datetime
|
437
|
+
v = cell.text
|
407
438
|
elsif tmp_type == :formula
|
408
439
|
vt = :formula
|
409
440
|
v = cell.text.to_f #TODO: !!!!
|
@@ -411,6 +442,7 @@ def celltype(row,col,sheet=nil)
|
|
411
442
|
vt = :float
|
412
443
|
v = cell.text
|
413
444
|
end
|
445
|
+
#puts "vt: #{vt}" if cell.text.include? "22606.5120"
|
414
446
|
x,y = split_coordinate(row.attributes['r'])
|
415
447
|
tr=nil #TODO: ???s
|
416
448
|
set_cell_values(sheet,x,y,0,v,vt,formula,tr,str_v,excelx_type,excelx_value,s_attribute)
|
data/lib/roo/google.rb
CHANGED
@@ -129,6 +129,14 @@ class Google < GenericSpreadsheet
|
|
129
129
|
return string.strip =~ /^([0-9]+):([0-9]+):([0-9]+)$/
|
130
130
|
end
|
131
131
|
|
132
|
+
# is String a date+time with format DD/MM/YYYY HH:MM:SS
|
133
|
+
def Google.datetime?(string)
|
134
|
+
return false if string.class == Float
|
135
|
+
return true if string.class == Date
|
136
|
+
return string.strip =~ /^([0-9]+)\/([0-9]+)\/([0-9]+)\ ([0-9]+):([0-9]+):([0-9]+)$/
|
137
|
+
end
|
138
|
+
|
139
|
+
|
132
140
|
def Google.timestring_to_seconds(value)
|
133
141
|
hms = value.split(':')
|
134
142
|
hms[0].to_i*3600 + hms[1].to_i*60 + hms[2].to_i
|
@@ -143,7 +151,6 @@ class Google < GenericSpreadsheet
|
|
143
151
|
check_default_sheet #TODO: 2007-12-16
|
144
152
|
read_cells(sheet) unless @cells_read[sheet]
|
145
153
|
row,col = normalize(row,col)
|
146
|
-
|
147
154
|
if celltype(row,col,sheet) == :date
|
148
155
|
yyyy,mm,dd = @cell[sheet]["#{row},#{col}"].split('-')
|
149
156
|
begin
|
@@ -151,7 +158,16 @@ class Google < GenericSpreadsheet
|
|
151
158
|
rescue ArgumentError
|
152
159
|
raise "Invalid date parameter: #{yyyy}, #{mm}, #{dd}"
|
153
160
|
end
|
154
|
-
|
161
|
+
elsif celltype(row,col,sheet) == :datetime
|
162
|
+
begin
|
163
|
+
date_part,time_part = @cell[sheet]["#{row},#{col}"].split(' ')
|
164
|
+
yyyy,mm,dd = date_part.split('-')
|
165
|
+
hh,mi,ss = time_part.split(':')
|
166
|
+
return DateTime.civil(yyyy.to_i,mm.to_i,dd.to_i,hh.to_i,mi.to_i,ss.to_i)
|
167
|
+
rescue ArgumentError
|
168
|
+
raise "Invalid date parameter: #{yyyy}, #{mm}, #{dd}, #{hh}, #{mi}, #{ss}"
|
169
|
+
end
|
170
|
+
end
|
155
171
|
return @cell[sheet]["#{row},#{col}"]
|
156
172
|
end
|
157
173
|
|
@@ -162,7 +178,7 @@ class Google < GenericSpreadsheet
|
|
162
178
|
# * :percentage
|
163
179
|
# * :formula
|
164
180
|
# * :time
|
165
|
-
|
181
|
+
# * :datetime
|
166
182
|
def celltype(row, col, sheet=nil)
|
167
183
|
sheet = @default_sheet unless sheet
|
168
184
|
read_cells(sheet) unless @cells_read[sheet]
|
@@ -345,6 +361,8 @@ class Google < GenericSpreadsheet
|
|
345
361
|
end
|
346
362
|
elsif Google.date?(value)
|
347
363
|
ty = :date
|
364
|
+
elsif Google.datetime?(value)
|
365
|
+
ty = :datetime
|
348
366
|
elsif numeric?(value) # or o.class ???
|
349
367
|
ty = :float
|
350
368
|
value = value.to_f
|
@@ -359,6 +377,12 @@ class Google < GenericSpreadsheet
|
|
359
377
|
if ty == :date
|
360
378
|
dd,mm,yyyy = value.split('/')
|
361
379
|
@cell[sheet][key] = sprintf("%04d-%02d-%02d",yyyy.to_i,mm.to_i,dd.to_i)
|
380
|
+
elsif ty == :datetime
|
381
|
+
date_part,time_part = value.split(' ')
|
382
|
+
dd,mm,yyyy = date_part.split('/')
|
383
|
+
hh,mi,ss = time_part.split(':')
|
384
|
+
@cell[sheet][key] = sprintf("%04d-%02d-%02d %02d:%02d:%02d",
|
385
|
+
yyyy.to_i,mm.to_i,dd.to_i,hh.to_i,mi.to_i,ss.to_i)
|
362
386
|
else
|
363
387
|
@cell[sheet][key] = value unless value == "" or value == nil
|
364
388
|
end
|
data/lib/roo/version.rb
CHANGED
data/test/test_roo.rb
CHANGED
@@ -13,8 +13,8 @@ require File.dirname(__FILE__) + '/test_helper.rb'
|
|
13
13
|
require 'fileutils'
|
14
14
|
require 'timeout'
|
15
15
|
require 'logger'
|
16
|
-
|
17
|
-
|
16
|
+
$log = Logger.new(File.join(ENV['HOME'],"roo.log"))
|
17
|
+
$log.level = Logger::WARN
|
18
18
|
#$log.level = Logger::DEBUG
|
19
19
|
|
20
20
|
DISPLAY_LOG = false
|
@@ -51,6 +51,7 @@ class Test::Unit::TestCase
|
|
51
51
|
"write.me" => 'ptu6bbahNZpY0N0RrxQbWdw&hl',
|
52
52
|
'formula' => 'o10837434939102457526.3022866619437760118',
|
53
53
|
'time-test' => 'ptu6bbahNZpYBMhk01UfXSg',
|
54
|
+
'datetime' => "ptu6bbahNZpYQEtZwzL_dZQ",
|
54
55
|
}[spreadsheetname]
|
55
56
|
rescue
|
56
57
|
raise "unknown spreadsheetname: #{spreadsheetname}"
|
@@ -107,7 +108,7 @@ class TestRoo < Test::Unit::TestCase
|
|
107
108
|
|
108
109
|
OPENOFFICE = true # do Openoffice-Spreadsheet Tests?
|
109
110
|
EXCEL = true # do Excel Tests?
|
110
|
-
GOOGLE =
|
111
|
+
GOOGLE = true # do Google-Spreadsheet Tests?
|
111
112
|
GNUMERIC_ODS = false # do gnumeric with ods files Tests?
|
112
113
|
EXCELX = true # do Excel-X Tests? (.xlsx-files)
|
113
114
|
|
@@ -1003,7 +1004,8 @@ class TestRoo < Test::Unit::TestCase
|
|
1003
1004
|
assert_raise(RangeError) { dummy = oo.empty?('C',5,"non existing sheet name")}
|
1004
1005
|
assert_raise(RangeError) { dummy = oo.formula?('C',5,"non existing sheet name")}
|
1005
1006
|
assert_raise(RangeError) { dummy = oo.formula('C',5,"non existing sheet name")}
|
1006
|
-
assert_raise(RangeError) { dummy = oo.set('C',5,42,"non existing sheet name")}
|
1007
|
+
#2008-12-04: assert_raise(RangeError) { dummy = oo.set('C',5,42,"non existing sheet name")}
|
1008
|
+
assert_raise(RangeError) { dummy = oo.set_value('C',5,42,"non existing sheet name")}
|
1007
1009
|
assert_raise(RangeError) { dummy = oo.formulas("non existing sheet name")}
|
1008
1010
|
assert_raise(RangeError) { dummy = oo.to_yaml({},1,1,1,1,"non existing sheet name")}
|
1009
1011
|
end
|
@@ -1970,16 +1972,20 @@ class TestRoo < Test::Unit::TestCase
|
|
1970
1972
|
end
|
1971
1973
|
|
1972
1974
|
def test_excel_zipped
|
1973
|
-
|
1974
|
-
|
1975
|
-
|
1976
|
-
|
1977
|
-
|
1975
|
+
after Date.new(2008,12,31) do
|
1976
|
+
if EXCEL
|
1977
|
+
$log.level = Logger::DEBUG
|
1978
|
+
excel = Excel.new(File.join("test","bode-v1.xls.zip"), :zip)
|
1979
|
+
assert excel
|
1980
|
+
# muss Fehler bringen, weil kein default_sheet gesetzt wurde
|
1981
|
+
assert_raises (ArgumentError) {
|
1982
|
+
assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
|
1983
|
+
}
|
1984
|
+
$log.level = Logger::WARN
|
1985
|
+
excel.default_sheet = excel.sheets.first
|
1978
1986
|
assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
|
1979
|
-
|
1980
|
-
|
1981
|
-
assert_equal 'ist "e" im Nenner von H(s)', excel.cell('b', 5)
|
1982
|
-
excel.remove_tmp # don't forget to remove the temporary files
|
1987
|
+
excel.remove_tmp # don't forget to remove the temporary files
|
1988
|
+
end
|
1983
1989
|
end
|
1984
1990
|
end
|
1985
1991
|
|
@@ -3392,26 +3398,28 @@ class TestRoo < Test::Unit::TestCase
|
|
3392
3398
|
end
|
3393
3399
|
|
3394
3400
|
def test_should_raise_file_not_found_error
|
3395
|
-
|
3396
|
-
|
3397
|
-
|
3398
|
-
|
3399
|
-
|
3400
|
-
|
3401
|
-
|
3402
|
-
|
3403
|
-
|
3404
|
-
|
3405
|
-
|
3406
|
-
|
3407
|
-
|
3408
|
-
|
3409
|
-
|
3410
|
-
|
3411
|
-
|
3412
|
-
|
3413
|
-
|
3414
|
-
|
3401
|
+
after Date.new(2008,12,31) do
|
3402
|
+
if OPENOFFICE
|
3403
|
+
assert_raise(IOError) {
|
3404
|
+
oo = Openoffice.new(File.join('testnichtvorhanden','Bibelbund.ods'))
|
3405
|
+
}
|
3406
|
+
end
|
3407
|
+
if EXCEL
|
3408
|
+
assert_raise(IOError) {
|
3409
|
+
oo = Excel.new(File.join('testnichtvorhanden','Bibelbund.xls'))
|
3410
|
+
}
|
3411
|
+
end
|
3412
|
+
if EXCELX
|
3413
|
+
assert_raise(IOError) {
|
3414
|
+
oo = Excelx.new(File.join('testnichtvorhanden','Bibelbund.xlsx'))
|
3415
|
+
}
|
3416
|
+
end
|
3417
|
+
if GOOGLE
|
3418
|
+
assert_raise(IOError) {
|
3419
|
+
# oo = Google.new(key_of('testnichtvorhanden'+'Bibelbund.ods'))
|
3420
|
+
oo = Google.new('testnichtvorhanden')
|
3421
|
+
}
|
3422
|
+
end
|
3415
3423
|
end
|
3416
3424
|
end
|
3417
3425
|
|
@@ -3868,7 +3876,6 @@ Sheet 3:
|
|
3868
3876
|
end
|
3869
3877
|
|
3870
3878
|
def test_bug_row_column_fixnum_float
|
3871
|
-
after Date.new(2008,9,15) do
|
3872
3879
|
if EXCEL
|
3873
3880
|
ex = Excel.new(File.join('test','bug-row-column-fixnum-float.xls'))
|
3874
3881
|
ex.default_sheet = ex.sheets.first
|
@@ -3877,8 +3884,7 @@ Sheet 3:
|
|
3877
3884
|
assert_equal ['hij',42.5, 43], ex.row(2)
|
3878
3885
|
assert_equal ['def',42.5, 'nop'], ex.column(2)
|
3879
3886
|
end
|
3880
|
-
|
3881
|
-
|
3887
|
+
|
3882
3888
|
end
|
3883
3889
|
|
3884
3890
|
def test_bug_c2
|
@@ -3908,7 +3914,7 @@ Sheet 3:
|
|
3908
3914
|
end
|
3909
3915
|
|
3910
3916
|
def test_bug_c2_parseexcel
|
3911
|
-
after Date.new(2008,11
|
3917
|
+
after Date.new(2008,12,11) do
|
3912
3918
|
local_only do
|
3913
3919
|
#-- this is OK
|
3914
3920
|
@workbook = Spreadsheet::ParseExcel.parse(File.join('test',"problem.xls"))
|
@@ -3987,7 +3993,7 @@ Sheet 3:
|
|
3987
3993
|
|
3988
3994
|
def test_compare_csv_excelx_excel
|
3989
3995
|
if EXCELX
|
3990
|
-
after Date.new(2008,
|
3996
|
+
after Date.new(2008,12,10) do
|
3991
3997
|
# parseexcel bug
|
3992
3998
|
local_only do
|
3993
3999
|
s1 = Excel.new(File.join("test","problem.xls"))
|
@@ -4009,7 +4015,7 @@ Sheet 3:
|
|
4009
4015
|
end
|
4010
4016
|
|
4011
4017
|
def test_problemx_csv_imported
|
4012
|
-
after Date.new(2008,
|
4018
|
+
after Date.new(2008,12,26) do
|
4013
4019
|
if EXCEL
|
4014
4020
|
local_only do
|
4015
4021
|
# wieder eingelesene CSV-Datei aus obigem Test
|
@@ -4158,24 +4164,24 @@ Sheet 3:
|
|
4158
4164
|
end
|
4159
4165
|
|
4160
4166
|
def test_open_from_uri
|
4161
|
-
|
4162
|
-
|
4163
|
-
|
4164
|
-
|
4165
|
-
|
4166
|
-
|
4167
|
-
|
4168
|
-
|
4169
|
-
|
4170
|
-
|
4167
|
+
if ONLINE
|
4168
|
+
if OPENOFFICE
|
4169
|
+
assert_raises(RuntimeError) {
|
4170
|
+
oo = Openoffice.new("http://gibbsnichtdomainxxxxx.com/file.ods")
|
4171
|
+
}
|
4172
|
+
end
|
4173
|
+
if EXCEL
|
4174
|
+
assert_raises(RuntimeError) {
|
4175
|
+
oo = Excel.new("http://gibbsnichtdomainxxxxx.com/file.xls")
|
4176
|
+
}
|
4177
|
+
end
|
4178
|
+
if EXCELX
|
4179
|
+
assert_raises(RuntimeError) {
|
4180
|
+
oo = Excelx.new("http://gibbsnichtdomainxxxxx.com/file.xlsx")
|
4181
|
+
}
|
4182
|
+
end
|
4171
4183
|
end
|
4172
|
-
if EXCELX
|
4173
|
-
assert_raises(RuntimeError) {
|
4174
|
-
oo = Excelx.new("http://gibbsnichtdomainxxxxx.com/file.xlsx")
|
4175
|
-
}
|
4176
4184
|
end
|
4177
|
-
end
|
4178
|
-
end
|
4179
4185
|
|
4180
4186
|
def test_bug_last_row_excel
|
4181
4187
|
if EXCEL
|
@@ -4622,35 +4628,39 @@ This attached file is the newer format of Microsoft Excel (.xlsx).
|
|
4622
4628
|
end
|
4623
4629
|
end
|
4624
4630
|
|
4631
|
+
def do_datetime_tests(oo)
|
4632
|
+
val = oo.cell('c',3)
|
4633
|
+
assert_kind_of DateTime, val
|
4634
|
+
assert_equal :datetime, oo.celltype('c',3)
|
4635
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), val
|
4636
|
+
val = oo.cell('a',1)
|
4637
|
+
assert_kind_of Date, val
|
4638
|
+
assert_equal :date, oo.celltype('a',1)
|
4639
|
+
assert_equal Date.new(1961,11,21), val
|
4640
|
+
|
4641
|
+
assert_equal Date.new(1961,11,21), oo.cell('a',1)
|
4642
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',3)
|
4643
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',3)
|
4644
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',3)
|
4645
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',4)
|
4646
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',4)
|
4647
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',4)
|
4648
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',5)
|
4649
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',5)
|
4650
|
+
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',5)
|
4651
|
+
assert_equal Date.new(1961,11,21), oo.cell('a',6)
|
4652
|
+
assert_equal Date.new(1961,11,21), oo.cell('b',6)
|
4653
|
+
assert_equal Date.new(1961,11,21), oo.cell('c',6)
|
4654
|
+
assert_equal Date.new(1961,11,21), oo.cell('a',7)
|
4655
|
+
assert_equal Date.new(1961,11,21), oo.cell('b',7)
|
4656
|
+
assert_equal Date.new(1961,11,21), oo.cell('c',7)
|
4657
|
+
end
|
4658
|
+
|
4625
4659
|
def test_datetime_openoffice
|
4626
4660
|
if OPENOFFICE
|
4627
4661
|
oo = Openoffice.new(File.join("test","datetime.ods"))
|
4628
4662
|
oo.default_sheet = oo.sheets.first
|
4629
|
-
|
4630
|
-
assert_kind_of DateTime, val
|
4631
|
-
assert_equal :datetime, oo.celltype('c',3)
|
4632
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), val
|
4633
|
-
val = oo.cell('a',1)
|
4634
|
-
assert_kind_of Date, val
|
4635
|
-
assert_equal :date, oo.celltype('a',1)
|
4636
|
-
assert_equal Date.new(1961,11,21), val
|
4637
|
-
|
4638
|
-
assert_equal Date.new(1961,11,21), oo.cell('a',1)
|
4639
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',3)
|
4640
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',3)
|
4641
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',3)
|
4642
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',4)
|
4643
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',4)
|
4644
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',4)
|
4645
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',5)
|
4646
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',5)
|
4647
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',5)
|
4648
|
-
assert_equal Date.new(1961,11,21), oo.cell('a',6)
|
4649
|
-
assert_equal Date.new(1961,11,21), oo.cell('b',6)
|
4650
|
-
assert_equal Date.new(1961,11,21), oo.cell('c',6)
|
4651
|
-
assert_equal Date.new(1961,11,21), oo.cell('a',7)
|
4652
|
-
assert_equal Date.new(1961,11,21), oo.cell('b',7)
|
4653
|
-
assert_equal Date.new(1961,11,21), oo.cell('c',7)
|
4663
|
+
do_datetime_tests(oo)
|
4654
4664
|
end
|
4655
4665
|
end
|
4656
4666
|
|
@@ -4658,97 +4668,27 @@ This attached file is the newer format of Microsoft Excel (.xlsx).
|
|
4658
4668
|
if EXCEL
|
4659
4669
|
oo = Excel.new(File.join("test","datetime.xls"))
|
4660
4670
|
oo.default_sheet = oo.sheets.first
|
4661
|
-
|
4662
|
-
assert_kind_of DateTime, val
|
4663
|
-
assert_equal :datetime, oo.celltype('c',3)
|
4664
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), val
|
4665
|
-
val = oo.cell('a',1)
|
4666
|
-
assert_kind_of Date, val
|
4667
|
-
assert_equal :date, oo.celltype('a',1)
|
4668
|
-
assert_equal Date.new(1961,11,21), val
|
4669
|
-
|
4670
|
-
assert_equal Date.new(1961,11,21), oo.cell('a',1)
|
4671
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',3)
|
4672
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',3)
|
4673
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',3)
|
4674
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',4)
|
4675
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',4)
|
4676
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',4)
|
4677
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',5)
|
4678
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',5)
|
4679
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',5)
|
4680
|
-
assert_equal Date.new(1961,11,21), oo.cell('a',6)
|
4681
|
-
assert_equal Date.new(1961,11,21), oo.cell('b',6)
|
4682
|
-
assert_equal Date.new(1961,11,21), oo.cell('c',6)
|
4683
|
-
assert_equal Date.new(1961,11,21), oo.cell('a',7)
|
4684
|
-
assert_equal Date.new(1961,11,21), oo.cell('b',7)
|
4685
|
-
assert_equal Date.new(1961,11,21), oo.cell('c',7)
|
4671
|
+
do_datetime_tests(oo)
|
4686
4672
|
end
|
4687
4673
|
end
|
4688
4674
|
|
4689
4675
|
def test_datetime_excelx
|
4690
|
-
|
4691
|
-
|
4692
|
-
|
4693
|
-
|
4694
|
-
val = oo.cell('c',3)
|
4695
|
-
assert_kind_of DateTime, val
|
4696
|
-
assert_equal :datetime, oo.celltype('c',3)
|
4697
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), val
|
4698
|
-
val = oo.cell('a',1)
|
4699
|
-
assert_kind_of Date, val
|
4700
|
-
assert_equal :date, oo.celltype('a',1)
|
4701
|
-
assert_equal Date.new(1961,11,21), val
|
4702
|
-
|
4703
|
-
assert_equal Date.new(1961,11,21), oo.cell('a',1)
|
4704
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',3)
|
4705
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',3)
|
4706
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',3)
|
4707
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',4)
|
4708
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',4)
|
4709
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',4)
|
4710
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',5)
|
4711
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',5)
|
4712
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',5)
|
4713
|
-
assert_equal Date.new(1961,11,21), oo.cell('a',6)
|
4714
|
-
assert_equal Date.new(1961,11,21), oo.cell('b',6)
|
4715
|
-
assert_equal Date.new(1961,11,21), oo.cell('c',6)
|
4716
|
-
assert_equal Date.new(1961,11,21), oo.cell('a',7)
|
4717
|
-
assert_equal Date.new(1961,11,21), oo.cell('b',7)
|
4718
|
-
assert_equal Date.new(1961,11,21), oo.cell('c',7)
|
4719
|
-
end
|
4676
|
+
if EXCELX
|
4677
|
+
oo = Excelx.new(File.join("test","datetime.xlsx"))
|
4678
|
+
oo.default_sheet = oo.sheets.first
|
4679
|
+
do_datetime_tests(oo)
|
4720
4680
|
end
|
4721
4681
|
end
|
4722
4682
|
|
4723
4683
|
def test_datetime_google
|
4724
4684
|
if GOOGLE
|
4725
|
-
|
4726
|
-
|
4727
|
-
|
4728
|
-
|
4729
|
-
|
4730
|
-
|
4731
|
-
|
4732
|
-
assert_kind_of Date, val
|
4733
|
-
assert_equal :date, oo.celltype('a',1)
|
4734
|
-
assert_equal Date.new(1961,11,21), val
|
4735
|
-
|
4736
|
-
assert_equal Date.new(1961,11,21), oo.cell('a',1)
|
4737
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',3)
|
4738
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',3)
|
4739
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',3)
|
4740
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',4)
|
4741
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',4)
|
4742
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',4)
|
4743
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('a',5)
|
4744
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('b',5)
|
4745
|
-
assert_equal DateTime.new(1961,11,21,12,17,18), oo.cell('c',5)
|
4746
|
-
assert_equal Date.new(1961,11,21), oo.cell('a',6)
|
4747
|
-
assert_equal Date.new(1961,11,21), oo.cell('b',6)
|
4748
|
-
assert_equal Date.new(1961,11,21), oo.cell('c',6)
|
4749
|
-
assert_equal Date.new(1961,11,21), oo.cell('a',7)
|
4750
|
-
assert_equal Date.new(1961,11,21), oo.cell('b',7)
|
4751
|
-
assert_equal Date.new(1961,11,21), oo.cell('c',7)
|
4685
|
+
begin
|
4686
|
+
oo = Google.new(key_of('datetime'))
|
4687
|
+
oo.default_sheet = oo.sheets.first
|
4688
|
+
do_datetime_tests(oo)
|
4689
|
+
ensure
|
4690
|
+
$log.level = Logger::WARN
|
4691
|
+
end
|
4752
4692
|
end
|
4753
4693
|
end
|
4754
4694
|
|
data/website/index.txt
CHANGED
@@ -138,6 +138,7 @@ returned:
|
|
138
138
|
* :percentage
|
139
139
|
* :formula
|
140
140
|
* :time
|
141
|
+
* :datetime
|
141
142
|
|
142
143
|
Numeric values are returned as type :float, the return value is a Ruby Float object (note: integer values like 42 are returned as 42.0 - not as a Fixnum 42 object).
|
143
144
|
|
@@ -145,6 +146,8 @@ String values are returned as type :string and Ruby String object.
|
|
145
146
|
|
146
147
|
Date values are returned as type :date and as a Ruby Date object.
|
147
148
|
|
149
|
+
Datetime values are returned as type :datedate and as a Ruby DateTime object.
|
150
|
+
|
148
151
|
Percentage are return as type :percentage and as Ruby Float object with the
|
149
152
|
range from 0.0 to 1.0.
|
150
153
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Preymesser
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-12-08 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|