summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/doc_props
diff options
context:
space:
mode:
authorStefan Daschek <[email protected]>2013-06-12 23:08:14 +0200
committerStefan Daschek <[email protected]>2013-06-12 23:08:14 +0200
commit0ec328213fbe31cd4456dceecda6d7ba8d1c9021 (patch)
treeb884e542ed423239ecac7bddefcfaede1c2d39a6 /lib/axlsx/doc_props
parent00cb09391927aaea08de304f3faad3afdbff2b18 (diff)
downloadcaxlsx-0ec328213fbe31cd4456dceecda6d7ba8d1c9021.tar.gz
caxlsx-0ec328213fbe31cd4456dceecda6d7ba8d1c9021.zip
Allow overriding the 'created' timestamp in the docprops.
Can be specified as option to Package#new: ``` Axlsx::Package.new :created_at => time ``` If omitted, the current time at the moment the document is serialized will be used. This change is therefore fully backward compatible.
Diffstat (limited to 'lib/axlsx/doc_props')
-rw-r--r--lib/axlsx/doc_props/core.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/axlsx/doc_props/core.rb b/lib/axlsx/doc_props/core.rb
index d71300e0..a74031f2 100644
--- a/lib/axlsx/doc_props/core.rb
+++ b/lib/axlsx/doc_props/core.rb
@@ -8,14 +8,19 @@ module Axlsx
# Creates a new Core object.
# @option options [String] creator
+ # @option options [Time] created
def initialize(options={})
@creator = options[:creator] || 'axlsx'
+ @created = options[:created]
end
# The author of the document. By default this is 'axlsx'
# @return [String]
attr_accessor :creator
+ # Creation time of the document. If nil, the current time will be used.
+ attr_accessor :created
+
# serializes the core.xml document
# @return [String]
def to_xml_string(str = '')
@@ -24,7 +29,7 @@ module Axlsx
str << 'xmlns:dcmitype="' << CORE_NS_DCMIT << '" xmlns:dcterms="' << CORE_NS_DCT << '" '
str << 'xmlns:xsi="' << CORE_NS_XSI << '">'
str << '<dc:creator>' << self.creator << '</dc:creator>'
- str << '<dcterms:created xsi:type="dcterms:W3CDTF">' << Time.now.strftime('%Y-%m-%dT%H:%M:%S') << 'Z</dcterms:created>'
+ str << '<dcterms:created xsi:type="dcterms:W3CDTF">' << (created || Time.now).strftime('%Y-%m-%dT%H:%M:%S') << 'Z</dcterms:created>'
str << '<cp:revision>0</cp:revision>'
str << '</cp:coreProperties>'
end