to_xl 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/to_xl.rb +40 -0
- metadata +45 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 6eaa03197b4a275939279ddeb4364dc2f6c51f03
|
|
4
|
+
data.tar.gz: 6649b5c871623880547eb58edbf4c951d2d8457c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 2c2f63c4c72a80be87cae9d2618aa2730c1d85838b415e954874cb529d97fa2036f089adee839f5c593170bb5402a58d6262390b07925c98eed3e7058bd80191
|
|
7
|
+
data.tar.gz: 8772c7c755661dde49f8b777af5041ec0fbf3d318d1d91fb0300c63992ad75bb7d025a2254d83ed92414be914e57dc6a1ff304d2d9d512552b1137e46151036d
|
data/lib/to_xl.rb
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'time'
|
|
2
|
+
|
|
3
|
+
class Time
|
|
4
|
+
|
|
5
|
+
def to_excel
|
|
6
|
+
@seconds_in_day ||= 24 * 60 * 60
|
|
7
|
+
@excel_days_offset ||= 25569
|
|
8
|
+
@offset_gmt = (self.hour > self.gmtime.hour) ? true : false # Excel dates are on GMT time, so we have to go back a day if this is calculated on one day in our time zone and another on GMT.
|
|
9
|
+
excel_date = (self.to_i/@seconds_in_day) + @excel_days_offset
|
|
10
|
+
excel_date -= 1 if @offset_gmt # Excel dates are on GMT time, so we have to go back a day if this is calculated on one day in our time zone and another on GMT.
|
|
11
|
+
excel_date
|
|
12
|
+
end
|
|
13
|
+
alias_method :to_xl, :to_excel
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
if defined?(Date)
|
|
19
|
+
class Date
|
|
20
|
+
|
|
21
|
+
def to_excel
|
|
22
|
+
self.to_time.to_excel
|
|
23
|
+
end
|
|
24
|
+
alias_method :to_xl, :to_excel
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
if defined?(DateTime)
|
|
31
|
+
class DateTime
|
|
32
|
+
|
|
33
|
+
def to_excel
|
|
34
|
+
self.to_time.to_excel
|
|
35
|
+
end
|
|
36
|
+
alias_method :to_xl, :to_excel
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
metadata
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: to_xl
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Brian Egan
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-01-20 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: A simple gem to convert Time, Date, and DateTime instances to Excel date
|
|
14
|
+
integers.
|
|
15
|
+
email: brianegan@outlook.com
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- lib/to_xl.rb
|
|
21
|
+
homepage: https://github.com/Brian-Egan/to_xl
|
|
22
|
+
licenses:
|
|
23
|
+
- MIT
|
|
24
|
+
metadata: {}
|
|
25
|
+
post_install_message:
|
|
26
|
+
rdoc_options: []
|
|
27
|
+
require_paths:
|
|
28
|
+
- lib
|
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
requirements: []
|
|
40
|
+
rubyforge_project:
|
|
41
|
+
rubygems_version: 2.4.5.1
|
|
42
|
+
signing_key:
|
|
43
|
+
specification_version: 4
|
|
44
|
+
summary: To Excel
|
|
45
|
+
test_files: []
|