roo 1.3.8 → 1.3.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/roo/excel.rb +55 -29
  2. data/lib/roo/version.rb +1 -1
  3. metadata +2 -2
@@ -12,42 +12,68 @@ end
12
12
  module Spreadsheet
13
13
  module Excel
14
14
  class Row < Spreadsheet::Row
15
+ def _datetime data # :nodoc:
16
+ return data if data.is_a?(DateTime)
17
+ base = @worksheet.date_base
18
+ date = base + data.to_f
19
+ hour = (data % 1) * 24
20
+ min = (hour % 1) * 60
21
+ sec = ((min % 1) * 60).round
22
+ min = min.floor
23
+ hour = hour.floor
24
+ if sec > 59
25
+ sec = 0
26
+ min += 1
27
+ end
28
+ if min > 59
29
+ min = 0
30
+ hour += 1
31
+ end
32
+ if hour > 23
33
+ hour = 0
34
+ date += 1
35
+ end
36
+ if LEAP_ERROR > base
37
+ date -= 1
38
+ end
39
+ DateTime.new(date.year, date.month, date.day, hour, min, sec)
40
+ end
15
41
  public :_date
16
42
  public :_datetime
17
43
  end
18
- # patch for ruby-spreadsheet parsing formulas
19
- class Reader
20
- def read_formula worksheet, addr, work
21
- row, column, xf, rtype, rval, rcheck, opts = work.unpack 'v3CxCx3v2'
22
- formula = Formula.new
23
- formula.shared = (opts & 0x08) > 0
24
- formula.data = work[20..-1]
25
- if rcheck != 0xffff || rtype > 3
26
- value, = work.unpack 'x6E'
27
- unless value
28
- # on architectures where sizeof(double) > 8
29
- value, = work.unpack 'x6e'
30
- end
31
- formula.value = value
32
- elsif rtype == 0
33
- pos, op, len, work = get_next_chunk
34
- if op == :string
35
- formula.value = client read_string(work, 2), @workbook.encoding
36
- else
37
- # This seems to work but I don't know why :). It at least
38
- # seems to correct the case we saw but doubtful it's the right fix
39
- formula.value = client read_string(work[10..-1], 2), @workbook.encoding
40
- end
41
- elsif rtype == 1
42
- formula.value = rval > 0
43
- elsif rtype == 2
44
- formula.value = Error.new rval
44
+ # patch for ruby-spreadsheet parsing formulas
45
+ class Reader
46
+ def read_formula worksheet, addr, work
47
+ row, column, xf, rtype, rval, rcheck, opts = work.unpack 'v3CxCx3v2'
48
+ formula = Formula.new
49
+ formula.shared = (opts & 0x08) > 0
50
+ formula.data = work[20..-1]
51
+ if rcheck != 0xffff || rtype > 3
52
+ value, = work.unpack 'x6E'
53
+ unless value
54
+ # on architectures where sizeof(double) > 8
55
+ value, = work.unpack 'x6e'
56
+ end
57
+ formula.value = value
58
+ elsif rtype == 0
59
+ pos, op, len, work = get_next_chunk
60
+ if op == :string
61
+ formula.value = client read_string(work, 2), @workbook.encoding
45
62
  else
46
- # leave the Formula value blank
63
+ # This seems to work but I don't know why :). It at least
64
+ # seems to correct the case we saw but doubtful it's the right fix
65
+ formula.value = client read_string(work[10..-1], 2), @workbook.encoding
47
66
  end
48
- set_cell worksheet, row, column, xf, formula
67
+ elsif rtype == 1
68
+ formula.value = rval > 0
69
+ elsif rtype == 2
70
+ formula.value = Error.new rval
71
+ else
72
+ # leave the Formula value blank
49
73
  end
74
+ set_cell worksheet, row, column, xf, formula
50
75
  end
76
+ end
51
77
  end
52
78
  end
53
79
 
@@ -2,7 +2,7 @@ module Roo #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 3
5
- TINY = 8
5
+ TINY = 9
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
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.3.8
4
+ version: 1.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hugh McGowan
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-07-18 00:00:00 -05:00
13
+ date: 2009-07-23 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency