drexed-datetime 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/drexed/datetime.rb +24 -22
- data/lib/drexed/datetime/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c2e2a88cec5ebc63836b5e7622adeadb1c7ae83
|
4
|
+
data.tar.gz: 9e16a9aaa6c4e6a74cc627944ab646fb2f5386c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c043cb3941f983ebdcabc8a8ae7e3efcc15022369c6791b694ebe18f9f92ccbdf2e7a9b154099b8cebc27819e497817b3c5ff13a8d1e275efd6cf8e073938201
|
7
|
+
data.tar.gz: 8355bf0e830d0eaa8ae62a24e7b1a3df093fae82e9d02cc7f89c89072b72f6dfe31d1f150c1d447885f1d2835b9eae59a4f21872d2f78181880ec8189e68b1a3
|
data/lib/drexed/datetime.rb
CHANGED
@@ -2,28 +2,30 @@ require "drexed/datetime/version"
|
|
2
2
|
|
3
3
|
module Drexed
|
4
4
|
module Datetime
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
5
|
+
class Engine < ::Rails::Engine
|
6
|
+
## Time.datetime_to("yyyy-mm-dd") => "2012-03-04"
|
7
|
+
def datetime_to(tach)
|
8
|
+
delineators = tach.scan /\W+/
|
9
|
+
formatters = tach.scan /[a-z]+/i
|
10
|
+
units = { "yy" => "y",
|
11
|
+
"yyyy" => "Y",
|
12
|
+
"m" => "-m",
|
13
|
+
"mm" => "m",
|
14
|
+
"M" => "b",
|
15
|
+
"MM" => "B",
|
16
|
+
"d" => "-d",
|
17
|
+
"dd" => "d",
|
18
|
+
"D" => "a",
|
19
|
+
"DD" => "A",
|
20
|
+
"h" => "-I",
|
21
|
+
"hh" => "I",
|
22
|
+
"H" => "-H",
|
23
|
+
"HH" => "H",
|
24
|
+
"mi" => "M",
|
25
|
+
"p" => "P",
|
26
|
+
"P" => "p" }
|
27
|
+
strftime(formatters.map{ |f| "%#{units[f]}#{delineators.shift || ""}" }.join)
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|