drexed-datetime 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -29
- data/lib/drexed/datetime.rb +1 -28
- 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: 4c88ef46a63794fef490a8a06a6aed0f7b058699
|
4
|
+
data.tar.gz: afdbd3b5bb15093ced8b6a5f6e40ffe413bfc783
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 731ea15fe616457cbefbdde767222673d980d3a179f08fff4cfad0a05bc99e3b204cea7bcd8407d5f75d6372fb6ad7d29c75a7b6f3db1bce1c4bc80422694b83
|
7
|
+
data.tar.gz: 32c459d41b79a2055a3c5f4baf1802c408475ccb53880d1ed508b25a7a6aa41e6b4c7a33ff7664cb5b30c5861e5bf79b6d81bf7f4335cf26a0b4f8b83b445346
|
data/README.md
CHANGED
@@ -46,32 +46,4 @@ Or install it yourself as:
|
|
46
46
|
| abbr_date_for | Dec 4, 2013 |
|
47
47
|
| month_and_day_for | December 4 |
|
48
48
|
| abbr_month_and_day_for | Dec 4 |
|
49
|
-
| timezone_name_for | EST |
|
50
|
-
|
51
|
-
## Datetime formatter
|
52
|
-
|
53
|
-
```ruby
|
54
|
-
Time.now.datetime_to("yyyy-mm-dd") => "2012-03-04"
|
55
|
-
Time.now.datetime_to("M d, yy") => "Mar 4, 12"
|
56
|
-
Time.now.datetime_to("hh:mi p") => "02:06 pm"
|
57
|
-
```
|
58
|
-
|
59
|
-
| Format string | `strftime` equivalent | Output for `t` |
|
60
|
-
| --- | --- | --- |
|
61
|
-
| "yyyy" | "%Y"| 2013|
|
62
|
-
| "yy" | "%y"| 13|
|
63
|
-
| "mm" | "%m" | 03 |
|
64
|
-
| "m" | "%-m" | 3 |
|
65
|
-
| "MM" | "%B" | March |
|
66
|
-
| "M" | "%b" | Mar |
|
67
|
-
| "dd" | "%d" | 04 |
|
68
|
-
| "d" | "%-d" | 4 |
|
69
|
-
| "DD" | "%A" | Sunday |
|
70
|
-
| "D" | "%a" | Sun |
|
71
|
-
| "hh" | "%I" | 02 |
|
72
|
-
| "h" | "%l" | 2 |
|
73
|
-
| "HH" | "%H" | 14 |
|
74
|
-
| "H" | "%-H" | 14 |
|
75
|
-
| "mi" | "%M" | 06 |
|
76
|
-
| "p" | "%P" | pm |
|
77
|
-
| "P" | "%p" | PM |
|
49
|
+
| timezone_name_for | EST |
|
data/lib/drexed/datetime.rb
CHANGED
@@ -3,33 +3,6 @@ require "drexed/datetime/version"
|
|
3
3
|
module Drexed
|
4
4
|
module Datetime
|
5
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
|
29
6
|
end
|
30
7
|
end
|
31
|
-
end
|
32
|
-
|
33
|
-
Time.send :include, Drexed::Datetime
|
34
|
-
Date.send :include, Drexed::Datetime
|
35
|
-
DateTime.send :include, Drexed::Datetime
|
8
|
+
end
|