writeexcel 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. data/.gitattributes +1 -1
  2. data/.gitignore +24 -24
  3. data/README.rdoc +34 -55
  4. data/VERSION +1 -1
  5. data/charts/chartex.rb +316 -316
  6. data/charts/demo1.rb +46 -46
  7. data/charts/demo2.rb +65 -65
  8. data/charts/demo3.rb +117 -117
  9. data/charts/demo4.rb +119 -119
  10. data/charts/demo5.rb +48 -48
  11. data/examples/a_simple.rb +43 -43
  12. data/examples/autofilter.rb +265 -265
  13. data/examples/bigfile.rb +30 -30
  14. data/examples/chart_area.rb +121 -121
  15. data/examples/chart_bar.rb +120 -120
  16. data/examples/chart_column.rb +120 -120
  17. data/examples/chart_line.rb +120 -120
  18. data/examples/chart_pie.rb +108 -108
  19. data/examples/chart_scatter.rb +121 -121
  20. data/examples/chart_stock.rb +148 -148
  21. data/examples/chess.rb +142 -142
  22. data/examples/colors.rb +129 -129
  23. data/examples/comments1.rb +27 -27
  24. data/examples/comments2.rb +352 -352
  25. data/examples/copyformat.rb +52 -52
  26. data/examples/data_validate.rb +279 -279
  27. data/examples/date_time.rb +87 -87
  28. data/examples/defined_name.rb +32 -32
  29. data/examples/demo.rb +124 -124
  30. data/examples/diag_border.rb +36 -36
  31. data/examples/formats.rb +490 -490
  32. data/examples/formula_result.rb +30 -30
  33. data/examples/header.rb +137 -137
  34. data/examples/hide_sheet.rb +29 -29
  35. data/examples/hyperlink.rb +43 -43
  36. data/examples/images.rb +63 -63
  37. data/examples/indent.rb +31 -31
  38. data/examples/merge1.rb +40 -40
  39. data/examples/merge2.rb +45 -45
  40. data/examples/merge3.rb +66 -66
  41. data/examples/merge4.rb +83 -83
  42. data/examples/merge5.rb +80 -80
  43. data/examples/merge6.rb +67 -67
  44. data/examples/outline.rb +255 -255
  45. data/examples/outline_collapsed.rb +209 -209
  46. data/examples/panes.rb +113 -113
  47. data/examples/properties.rb +34 -34
  48. data/examples/properties_jp.rb +33 -33
  49. data/examples/protection.rb +47 -47
  50. data/examples/regions.rb +53 -53
  51. data/examples/repeat.rb +43 -43
  52. data/examples/right_to_left.rb +27 -27
  53. data/examples/row_wrap.rb +53 -53
  54. data/examples/stats.rb +74 -74
  55. data/examples/stocks.rb +81 -81
  56. data/examples/tab_colors.rb +31 -31
  57. data/examples/utf8.rb +15 -15
  58. data/examples/write_arrays.rb +83 -83
  59. data/lib/writeexcel/biffwriter.rb +232 -232
  60. data/lib/writeexcel/caller_info.rb +12 -12
  61. data/lib/writeexcel/chart.rb +2190 -2177
  62. data/lib/writeexcel/charts/area.rb +154 -154
  63. data/lib/writeexcel/charts/bar.rb +177 -177
  64. data/lib/writeexcel/charts/column.rb +156 -156
  65. data/lib/writeexcel/charts/external.rb +66 -66
  66. data/lib/writeexcel/charts/line.rb +154 -154
  67. data/lib/writeexcel/charts/pie.rb +169 -169
  68. data/lib/writeexcel/charts/scatter.rb +192 -192
  69. data/lib/writeexcel/charts/stock.rb +213 -213
  70. data/lib/writeexcel/colors.rb +64 -64
  71. data/lib/writeexcel/compatibility.rb +0 -255
  72. data/lib/writeexcel/debug_info.rb +37 -33
  73. data/lib/writeexcel/excelformulaparser.rb +587 -587
  74. data/lib/writeexcel/format.rb +13 -4
  75. data/lib/writeexcel/formula.rb +26 -9
  76. data/lib/writeexcel/helper.rb +68 -64
  77. data/lib/writeexcel/olewriter.rb +311 -311
  78. data/lib/writeexcel/properties.rb +242 -240
  79. data/lib/writeexcel/storage_lite.rb +984 -978
  80. data/lib/writeexcel/workbook.rb +3210 -3192
  81. data/lib/writeexcel/worksheet.rb +143 -51
  82. data/lib/writeexcel/write_file.rb +44 -40
  83. data/lib/writeexcel.rb +1159 -1159
  84. data/test/helper.rb +31 -28
  85. data/test/perl_output/README +31 -31
  86. data/test/test_00_IEEE_double.rb +13 -13
  87. data/test/test_01_add_worksheet.rb +10 -10
  88. data/test/test_02_merge_formats.rb +53 -53
  89. data/test/test_04_dimensions.rb +392 -392
  90. data/test/test_05_rows.rb +179 -179
  91. data/test/test_06_extsst.rb +77 -77
  92. data/test/test_11_date_time.rb +479 -479
  93. data/test/test_12_date_only.rb +501 -501
  94. data/test/test_13_date_seconds.rb +481 -481
  95. data/test/test_21_escher.rb +637 -637
  96. data/test/test_22_mso_drawing_group.rb +745 -745
  97. data/test/test_23_note.rb +73 -73
  98. data/test/test_24_txo.rb +75 -75
  99. data/test/test_25_position_object.rb +84 -84
  100. data/test/test_26_autofilter.rb +314 -314
  101. data/test/test_27_autofilter.rb +131 -131
  102. data/test/test_28_autofilter.rb +161 -161
  103. data/test/test_29_process_jpg.rb +683 -683
  104. data/test/test_30_validation_dval.rb +77 -77
  105. data/test/test_31_validation_dv_strings.rb +126 -126
  106. data/test/test_32_validation_dv_formula.rb +206 -206
  107. data/test/test_40_property_types.rb +188 -188
  108. data/test/test_41_properties.rb +235 -235
  109. data/test/test_42_set_properties.rb +437 -437
  110. data/test/test_50_name_stored.rb +299 -299
  111. data/test/test_51_name_print_area.rb +357 -357
  112. data/test/test_52_name_print_titles.rb +454 -454
  113. data/test/test_53_autofilter.rb +203 -203
  114. data/test/test_60_chart_generic.rb +578 -578
  115. data/test/test_61_chart_subclasses.rb +95 -95
  116. data/test/test_62_chart_formats.rb +272 -272
  117. data/test/test_63_chart_area_formats.rb +649 -649
  118. data/test/test_biff.rb +75 -75
  119. data/test/test_compatibility.rb +12 -627
  120. data/test/test_example_match.rb +3144 -3144
  121. data/test/test_formula.rb +61 -61
  122. data/test/test_ole.rb +106 -106
  123. data/test/test_storage_lite.rb +125 -125
  124. data/test/test_workbook.rb +139 -139
  125. data/test/test_worksheet.rb +110 -110
  126. data/utils/add_magic_comment.rb +80 -80
  127. data/writeexcel.gemspec +4 -6
  128. data/writeexcel.rdoc +58 -15
  129. metadata +9 -6
  130. data/test/test_new_encoding.rb +0 -205
@@ -1,240 +1,242 @@
1
- # -*- coding: utf-8 -*-
2
- ###############################################################################
3
- #
4
- # Properties - A module for creating Excel property sets.
5
- #
6
- #
7
- # Used in conjunction with WriteExcel
8
- #
9
- # Copyright 2000-2010, John McNamara.
10
- #
11
- # original written in Perl by John McNamara
12
- # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
13
- #
14
-
15
- require 'date'
16
-
17
- ###############################################################################
18
- #
19
- # create_summary_property_set().
20
- #
21
- # Create the SummaryInformation property set. This is mainly used for the
22
- # Title, Subject, Author, Keywords, Comments, Last author keywords and the
23
- # creation date.
24
- #
25
- def create_summary_property_set(properties) #:nodoc:
26
- byte_order = [0xFFFE].pack('v')
27
- version = [0x0000].pack('v')
28
- system_id = [0x00020105].pack('V')
29
- class_id = ['00000000000000000000000000000000'].pack('H*')
30
- num_property_sets = [0x0001].pack('V')
31
- format_id = ['E0859FF2F94F6810AB9108002B27B3D9'].pack('H*')
32
- offset = [0x0030].pack('V')
33
- num_property = [properties.size].pack('V')
34
- property_offsets = ''
35
-
36
- # Create the property set data block and calculate the offsets into it.
37
- property_data, offsets = pack_property_data(properties)
38
-
39
- # Create the property type and offsets based on the previous calculation.
40
- 0.upto(properties.size - 1) do |i|
41
- property_offsets += [properties[i][0], offsets[i]].pack('VV')
42
- end
43
-
44
- # Size of size (4 bytes) + num_property (4 bytes) + the data structures.
45
- size = 8 + (property_offsets).bytesize + property_data.bytesize
46
- size = [size].pack('V')
47
-
48
- byte_order +
49
- version +
50
- system_id +
51
- class_id +
52
- num_property_sets +
53
- format_id +
54
- offset +
55
- size +
56
- num_property +
57
- property_offsets +
58
- property_data
59
- end
60
-
61
-
62
- ###############################################################################
63
- #
64
- # Create the DocSummaryInformation property set. This is mainly used for the
65
- # Manager, Company and Category keywords.
66
- #
67
- # The DocSummary also contains a stream for user defined properties. However
68
- # this is a little arcane and probably not worth the implementation effort.
69
- #
70
- def create_doc_summary_property_set(properties) #:nodoc:
71
- byte_order = [0xFFFE].pack('v')
72
- version = [0x0000].pack('v')
73
- system_id = [0x00020105].pack('V')
74
- class_id = ['00000000000000000000000000000000'].pack('H*')
75
- num_property_sets = [0x0002].pack('V')
76
-
77
- format_id_0 = ['02D5CDD59C2E1B10939708002B2CF9AE'].pack('H*')
78
- format_id_1 = ['05D5CDD59C2E1B10939708002B2CF9AE'].pack('H*')
79
- offset_0 = [0x0044].pack('V')
80
- num_property_0 = [properties.size].pack('V')
81
- property_offsets_0 = ''
82
-
83
- # Create the property set data block and calculate the offsets into it.
84
- property_data_0, offsets = pack_property_data(properties)
85
-
86
- # Create the property type and offsets based on the previous calculation.
87
- 0.upto(properties.size-1) do |i|
88
- property_offsets_0 += [properties[i][0], offsets[i]].pack('VV')
89
- end
90
-
91
- # Size of size (4 bytes) + num_property (4 bytes) + the data structures.
92
- data_len = 8 + (property_offsets_0).bytesize + property_data_0.bytesize
93
- size_0 = [data_len].pack('V')
94
-
95
- # The second property set offset is at the end of the first property set.
96
- offset_1 = [0x0044 + data_len].pack('V')
97
-
98
- # We will use a static property set stream rather than try to generate it.
99
- property_data_1 = [%w(
100
- 98 00 00 00 03 00 00 00 00 00 00 00 20 00 00 00
101
- 01 00 00 00 36 00 00 00 02 00 00 00 3E 00 00 00
102
- 01 00 00 00 02 00 00 00 0A 00 00 00 5F 50 49 44
103
- 5F 47 55 49 44 00 02 00 00 00 E4 04 00 00 41 00
104
- 00 00 4E 00 00 00 7B 00 31 00 36 00 43 00 34 00
105
- 42 00 38 00 33 00 42 00 2D 00 39 00 36 00 35 00
106
- 46 00 2D 00 34 00 42 00 32 00 31 00 2D 00 39 00
107
- 30 00 33 00 44 00 2D 00 39 00 31 00 30 00 46 00
108
- 41 00 44 00 46 00 41 00 37 00 30 00 31 00 42 00
109
- 7D 00 00 00 00 00 00 00 2D 00 39 00 30 00 33 00
110
- ).join('')].pack('H*')
111
-
112
- byte_order +
113
- version +
114
- system_id +
115
- class_id +
116
- num_property_sets +
117
- format_id_0 +
118
- offset_0 +
119
- format_id_1 +
120
- offset_1 +
121
- size_0 +
122
- num_property_0 +
123
- property_offsets_0 +
124
- property_data_0 +
125
- property_data_1
126
- end
127
-
128
-
129
- ###############################################################################
130
- #
131
- # _pack_property_data().
132
- #
133
- # Create a packed property set structure. Strings are null terminated and
134
- # padded to a 4 byte boundary. We also use this function to keep track of the
135
- # property offsets within the data structure. These offsets are used by the
136
- # calling functions. Currently we only need to handle 4 property types:
137
- # VT_I2, VT_LPSTR, VT_FILETIME.
138
- #
139
- def pack_property_data(properties, offset = 0) #:nodoc:
140
- packed_property = ''
141
- data = ''
142
- offsets = []
143
-
144
- # Get the strings codepage from the first property.
145
- codepage = properties[0][2]
146
-
147
- # The properties start after 8 bytes for size + num_properties + 8 bytes
148
- # for each propety type/offset pair.
149
- offset += 8 * (properties.size + 1)
150
-
151
- properties.each do |property|
152
- offsets.push(offset)
153
-
154
- property_type = property[1]
155
-
156
- if property_type == 'VT_I2'
157
- packed_property = pack_VT_I2(property[2])
158
- elsif property_type == 'VT_LPSTR'
159
- packed_property = pack_VT_LPSTR(property[2], codepage)
160
- elsif property_type == 'VT_FILETIME'
161
- packed_property = pack_VT_FILETIME(property[2])
162
- else
163
- raise "Unknown property type: '#{property_type}'\n"
164
- end
165
-
166
- offset += packed_property.bytesize
167
- data += packed_property
168
- end
169
-
170
- [data, offsets]
171
- end
172
-
173
- ###############################################################################
174
- #
175
- # _pack_VT_I2().
176
- #
177
- # Pack an OLE property type: VT_I2, 16-bit signed integer.
178
- #
179
- def pack_VT_I2(value) #:nodoc:
180
- type = 0x0002
181
- data = [type, value].pack('VV')
182
- end
183
-
184
- ###############################################################################
185
- #
186
- # _pack_VT_LPSTR().
187
- #
188
- # Pack an OLE property type: VT_LPSTR, String in the Codepage encoding.
189
- # The strings are null terminated and padded to a 4 byte boundary.
190
- #
191
- def pack_VT_LPSTR(str, codepage) #:nodoc:
192
- type = 0x001E
193
- string = str.force_encoding('BINARY') + "\0".encode('BINARY')
194
-
195
- if codepage == 0x04E4
196
- # Latin1
197
- length = string.bytesize
198
- elsif codepage == 0xFDE9
199
- # utf8
200
- length = string.bytesize
201
- else
202
- raise "Unknown codepage: #{codepage}\n"
203
- end
204
-
205
- # Pack the data.
206
- data = [type, length].pack('VV')
207
- data += string
208
-
209
- # The packed data has to null padded to a 4 byte boundary.
210
- if (extra = length % 4) != 0
211
- data += "\0" * (4 - extra)
212
- end
213
- data
214
- end
215
-
216
- ###############################################################################
217
- #
218
- # _pack_VT_FILETIME().
219
- #
220
- # Pack an OLE property type: VT_FILETIME.
221
- #
222
- def pack_VT_FILETIME(localtime) #:nodoc:
223
- type = 0x0040
224
-
225
- epoch = DateTime.new(1601, 1, 1)
226
-
227
- datetime = DateTime.new(
228
- localtime.year,
229
- localtime.mon,
230
- localtime.mday,
231
- localtime.hour,
232
- localtime.min,
233
- localtime.sec,
234
- localtime.usec
235
- )
236
- bignum = (datetime - epoch) * 86400 * 1e7.to_i
237
- high, low = bignum.divmod 1 << 32
238
-
239
- [type].pack('V') + [low, high].pack('V2')
240
- end
1
+ # -*- coding: utf-8 -*-
2
+ ###############################################################################
3
+ #
4
+ # Properties - A module for creating Excel property sets.
5
+ #
6
+ #
7
+ # Used in conjunction with WriteExcel
8
+ #
9
+ # Copyright 2000-2010, John McNamara.
10
+ #
11
+ # original written in Perl by John McNamara
12
+ # converted to Ruby by Hideo Nakamura, cxn03651@msj.biglobe.ne.jp
13
+ #
14
+
15
+ require 'date'
16
+
17
+ ###############################################################################
18
+ #
19
+ # create_summary_property_set().
20
+ #
21
+ # Create the SummaryInformation property set. This is mainly used for the
22
+ # Title, Subject, Author, Keywords, Comments, Last author keywords and the
23
+ # creation date.
24
+ #
25
+ def create_summary_property_set(properties) #:nodoc:
26
+ byte_order = [0xFFFE].pack('v')
27
+ version = [0x0000].pack('v')
28
+ system_id = [0x00020105].pack('V')
29
+ class_id = ['00000000000000000000000000000000'].pack('H*')
30
+ num_property_sets = [0x0001].pack('V')
31
+ format_id = ['E0859FF2F94F6810AB9108002B27B3D9'].pack('H*')
32
+ offset = [0x0030].pack('V')
33
+ num_property = [properties.size].pack('V')
34
+ property_offsets = ''
35
+
36
+ # Create the property set data block and calculate the offsets into it.
37
+ property_data, offsets = pack_property_data(properties)
38
+
39
+ # Create the property type and offsets based on the previous calculation.
40
+ 0.upto(properties.size - 1) do |i|
41
+ property_offsets += [properties[i][0], offsets[i]].pack('VV')
42
+ end
43
+
44
+ # Size of size (4 bytes) + num_property (4 bytes) + the data structures.
45
+ size = 8 + (property_offsets).bytesize + property_data.bytesize
46
+ size = [size].pack('V')
47
+
48
+ byte_order +
49
+ version +
50
+ system_id +
51
+ class_id +
52
+ num_property_sets +
53
+ format_id +
54
+ offset +
55
+ size +
56
+ num_property +
57
+ property_offsets +
58
+ property_data
59
+ end
60
+
61
+
62
+ ###############################################################################
63
+ #
64
+ # Create the DocSummaryInformation property set. This is mainly used for the
65
+ # Manager, Company and Category keywords.
66
+ #
67
+ # The DocSummary also contains a stream for user defined properties. However
68
+ # this is a little arcane and probably not worth the implementation effort.
69
+ #
70
+ def create_doc_summary_property_set(properties) #:nodoc:
71
+ byte_order = [0xFFFE].pack('v')
72
+ version = [0x0000].pack('v')
73
+ system_id = [0x00020105].pack('V')
74
+ class_id = ['00000000000000000000000000000000'].pack('H*')
75
+ num_property_sets = [0x0002].pack('V')
76
+
77
+ format_id_0 = ['02D5CDD59C2E1B10939708002B2CF9AE'].pack('H*')
78
+ format_id_1 = ['05D5CDD59C2E1B10939708002B2CF9AE'].pack('H*')
79
+ offset_0 = [0x0044].pack('V')
80
+ num_property_0 = [properties.size].pack('V')
81
+ property_offsets_0 = ''
82
+
83
+ # Create the property set data block and calculate the offsets into it.
84
+ property_data_0, offsets = pack_property_data(properties)
85
+
86
+ # Create the property type and offsets based on the previous calculation.
87
+ 0.upto(properties.size-1) do |i|
88
+ property_offsets_0 += [properties[i][0], offsets[i]].pack('VV')
89
+ end
90
+
91
+ # Size of size (4 bytes) + num_property (4 bytes) + the data structures.
92
+ data_len = 8 + (property_offsets_0).bytesize + property_data_0.bytesize
93
+ size_0 = [data_len].pack('V')
94
+
95
+ # The second property set offset is at the end of the first property set.
96
+ offset_1 = [0x0044 + data_len].pack('V')
97
+
98
+ # We will use a static property set stream rather than try to generate it.
99
+ property_data_1 = [%w(
100
+ 98 00 00 00 03 00 00 00 00 00 00 00 20 00 00 00
101
+ 01 00 00 00 36 00 00 00 02 00 00 00 3E 00 00 00
102
+ 01 00 00 00 02 00 00 00 0A 00 00 00 5F 50 49 44
103
+ 5F 47 55 49 44 00 02 00 00 00 E4 04 00 00 41 00
104
+ 00 00 4E 00 00 00 7B 00 31 00 36 00 43 00 34 00
105
+ 42 00 38 00 33 00 42 00 2D 00 39 00 36 00 35 00
106
+ 46 00 2D 00 34 00 42 00 32 00 31 00 2D 00 39 00
107
+ 30 00 33 00 44 00 2D 00 39 00 31 00 30 00 46 00
108
+ 41 00 44 00 46 00 41 00 37 00 30 00 31 00 42 00
109
+ 7D 00 00 00 00 00 00 00 2D 00 39 00 30 00 33 00
110
+ ).join('')].pack('H*')
111
+
112
+ byte_order +
113
+ version +
114
+ system_id +
115
+ class_id +
116
+ num_property_sets +
117
+ format_id_0 +
118
+ offset_0 +
119
+ format_id_1 +
120
+ offset_1 +
121
+ size_0 +
122
+ num_property_0 +
123
+ property_offsets_0 +
124
+ property_data_0 +
125
+ property_data_1
126
+ end
127
+
128
+
129
+ ###############################################################################
130
+ #
131
+ # _pack_property_data().
132
+ #
133
+ # Create a packed property set structure. Strings are null terminated and
134
+ # padded to a 4 byte boundary. We also use this function to keep track of the
135
+ # property offsets within the data structure. These offsets are used by the
136
+ # calling functions. Currently we only need to handle 4 property types:
137
+ # VT_I2, VT_LPSTR, VT_FILETIME.
138
+ #
139
+ def pack_property_data(properties, offset = 0) #:nodoc:
140
+ packed_property = ''
141
+ data = ''
142
+ offsets = []
143
+
144
+ # Get the strings codepage from the first property.
145
+ codepage = properties[0][2]
146
+
147
+ # The properties start after 8 bytes for size + num_properties + 8 bytes
148
+ # for each propety type/offset pair.
149
+ offset += 8 * (properties.size + 1)
150
+
151
+ properties.each do |property|
152
+ offsets.push(offset)
153
+
154
+ property_type = property[1]
155
+
156
+ if property_type == 'VT_I2'
157
+ packed_property = pack_VT_I2(property[2])
158
+ elsif property_type == 'VT_LPSTR'
159
+ packed_property = pack_VT_LPSTR(property[2], codepage)
160
+ elsif property_type == 'VT_FILETIME'
161
+ packed_property = pack_VT_FILETIME(property[2])
162
+ else
163
+ raise "Unknown property type: '#{property_type}'\n"
164
+ end
165
+
166
+ offset += packed_property.bytesize
167
+ data += packed_property
168
+ end
169
+
170
+ [data, offsets]
171
+ end
172
+
173
+ ###############################################################################
174
+ #
175
+ # _pack_VT_I2().
176
+ #
177
+ # Pack an OLE property type: VT_I2, 16-bit signed integer.
178
+ #
179
+ def pack_VT_I2(value) #:nodoc:
180
+ type = 0x0002
181
+ data = [type, value].pack('VV')
182
+ end
183
+
184
+ ###############################################################################
185
+ #
186
+ # _pack_VT_LPSTR().
187
+ #
188
+ # Pack an OLE property type: VT_LPSTR, String in the Codepage encoding.
189
+ # The strings are null terminated and padded to a 4 byte boundary.
190
+ #
191
+ def pack_VT_LPSTR(str, codepage) #:nodoc:
192
+ type = 0x001E
193
+ string =
194
+ ruby_18 { "#{str}\0" } ||
195
+ ruby_19 { str.force_encoding('BINARY') + "\0".encode('BINARY') }
196
+
197
+ if codepage == 0x04E4
198
+ # Latin1
199
+ length = string.bytesize
200
+ elsif codepage == 0xFDE9
201
+ # utf8
202
+ length = string.bytesize
203
+ else
204
+ raise "Unknown codepage: #{codepage}\n"
205
+ end
206
+
207
+ # Pack the data.
208
+ data = [type, length].pack('VV')
209
+ data += string
210
+
211
+ # The packed data has to null padded to a 4 byte boundary.
212
+ if (extra = length % 4) != 0
213
+ data += "\0" * (4 - extra)
214
+ end
215
+ data
216
+ end
217
+
218
+ ###############################################################################
219
+ #
220
+ # _pack_VT_FILETIME().
221
+ #
222
+ # Pack an OLE property type: VT_FILETIME.
223
+ #
224
+ def pack_VT_FILETIME(localtime) #:nodoc:
225
+ type = 0x0040
226
+
227
+ epoch = DateTime.new(1601, 1, 1)
228
+
229
+ datetime = DateTime.new(
230
+ localtime.year,
231
+ localtime.mon,
232
+ localtime.mday,
233
+ localtime.hour,
234
+ localtime.min,
235
+ localtime.sec,
236
+ localtime.usec
237
+ )
238
+ bignum = (datetime - epoch) * 86400 * 1e7.to_i
239
+ high, low = bignum.divmod 1 << 32
240
+
241
+ [type].pack('V') + [low, high].pack('V2')
242
+ end