stamp 0.1.1 → 0.1.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.
- data/.travis.yml +0 -1
- data/Gemfile.lock +1 -1
- data/README.md +26 -11
- data/lib/stamp/version.rb +1 -1
- metadata +2 -2
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# stamp
|
2
2
|
|
3
|
-
Format dates (and times, soon) based on examples, not arcane
|
3
|
+
Format dates (and times, soon) based on human-friendly examples, not arcane
|
4
|
+
strftime directives.
|
4
5
|
|
5
6
|
[](http://travis-ci.org/jeremyw/stamp)
|
6
7
|
|
@@ -10,9 +11,12 @@ Just `gem install stamp`, or add stamp to your Gemfile and `bundle install`.
|
|
10
11
|
|
11
12
|
## Usage
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
Your Ruby dates and times get a powerful new method: `stamp`.
|
15
|
+
|
16
|
+
### Dates
|
17
|
+
|
18
|
+
Give `Date#stamp` an example date string with whatever month, day, year,
|
19
|
+
and weekday parts you'd like, and your date will be formatted accordingly:
|
16
20
|
|
17
21
|
```ruby
|
18
22
|
date = Date.new(2011, 6, 9)
|
@@ -25,7 +29,21 @@ date.stamp("12/31/99") # "06/09/11"
|
|
25
29
|
date.stamp("DOB: 12/31/2000") # "DOB: 06/09/2011"
|
26
30
|
```
|
27
31
|
|
28
|
-
###
|
32
|
+
### Times
|
33
|
+
|
34
|
+
`Time#stamp` supports the same kinds of examples as `Date`, but also formats
|
35
|
+
hours, minutes, and seconds when it sees colon-separated values:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
time = Time.utc(2011, 6, 9, 20, 52, 30)
|
39
|
+
time.stamp("3:00 AM") # " 8:52 PM"
|
40
|
+
time.stamp("01:00:00 AM") # "08:52:30 PM"
|
41
|
+
time.stamp("23:59") # "20:52"
|
42
|
+
time.stamp("23:59:59") # "20:52:30"
|
43
|
+
time.stamp("Jan 1 at 01:00 AM") # "Jun 9 at 08:52 PM"
|
44
|
+
```
|
45
|
+
|
46
|
+
## Features
|
29
47
|
|
30
48
|
* Abbreviated and full names of months and weekdays are recognized.
|
31
49
|
* Days with or without a leading zero work instinctively.
|
@@ -46,22 +64,19 @@ future understand your intent.
|
|
46
64
|
|
47
65
|
### Limitations
|
48
66
|
|
49
|
-
*
|
50
|
-
|
51
|
-
Did I mention? Patches welcome!
|
67
|
+
* Time zone support hasn't been implemented. Patches welcome!
|
68
|
+
* DateTime support hasn't been implemented. Patches welcome!
|
52
69
|
|
53
70
|
If you need more obscure formatting options, you can include any valid
|
54
71
|
[strftime](http://strfti.me) directives in your example string, and they'll
|
55
72
|
just be passed along:
|
56
73
|
|
57
74
|
```ruby
|
58
|
-
|
75
|
+
Date.today.stamp("Week #%U, 1999") # "Week #23, 2011"
|
59
76
|
````
|
60
77
|
|
61
78
|
[Check out http://strfti.me](http://strfti.me) for more ideas.
|
62
79
|
|
63
|
-
More coming soon, including time formats by example.
|
64
|
-
|
65
80
|
## Contributing to stamp
|
66
81
|
|
67
82
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
data/lib/stamp/version.rb
CHANGED