fluid-time 0.2.1 → 0.2.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/README.md +4 -0
- data/VERSION +1 -1
- data/fluid-time.gemspec +2 -2
- data/lib/fluid-time.rb +19 -7
- data/spec/fluid-time_spec.rb +20 -0
- metadata +4 -4
data/README.md
CHANGED
@@ -4,6 +4,10 @@ Stop formatting time like a C-anderthal. Craft human readable time formats like
|
|
4
4
|
|
5
5
|
FluidTime.new('2012/04/10 21:22').month.day.th.comma.space.xs.year.txt('@').time.xz.xs.pm.lower.zone.to_s
|
6
6
|
# "April 10th, 2012 @ 9:22pm PDT"
|
7
|
+
|
8
|
+
FluidTime.new(Time.now).to_s
|
9
|
+
FluidTime.new(Date.today).to_s
|
10
|
+
FluidTime.new("21:22:00").to_s
|
7
11
|
|
8
12
|
Strip zeros, ordinalize, and change case with ease:
|
9
13
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/fluid-time.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{fluid-time}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Steve Lawson"]
|
12
|
-
s.date = %q{2012-
|
12
|
+
s.date = %q{2012-09-05}
|
13
13
|
s.description = %q{Stop formatting time like a C-anderthal. Craft human readable time formats like building a sentence.
|
14
14
|
> FluidTime.new('2012/04/10 21:22').month.day.th.comma.space.xs.year.txt('@').time.xz.xs.pm.lower.zone.to_s
|
15
15
|
=> "April 10th, 2012 @ 9:22pm PDT"
|
data/lib/fluid-time.rb
CHANGED
@@ -31,7 +31,9 @@ class FluidTime
|
|
31
31
|
j.yday.day_of_year
|
32
32
|
m.mm.mon.month_of_year
|
33
33
|
M.min.minute
|
34
|
-
p
|
34
|
+
hour.p
|
35
|
+
hour.pm.txt('or').hour.am
|
36
|
+
hour.PM.txt('or').hour.AM
|
35
37
|
S.sec.second
|
36
38
|
U
|
37
39
|
W
|
@@ -46,11 +48,11 @@ class FluidTime
|
|
46
48
|
db
|
47
49
|
usdate
|
48
50
|
W.th.comma.space._('week')
|
49
|
-
date.hour.colon.min.
|
51
|
+
date.hour.colon.min.today.pm
|
50
52
|
year.mmm.d.th
|
51
53
|
time.xs.p.down
|
52
|
-
txt('01').xz
|
53
|
-
txt('1:00').xz.
|
54
|
+
txt('01').xz.PM.zone
|
55
|
+
txt('1:00').xz.pm.zone
|
54
56
|
_('braces').lb.lp.lc.rc.rp.rb
|
55
57
|
_('symbols').lb.tp.ts.tc.ts.tn.ts.td.rb
|
56
58
|
_('symbols').lb.sp.ss.sc.ss.sn.ss.sd.rb
|
@@ -164,9 +166,14 @@ class FluidTime
|
|
164
166
|
|
165
167
|
|
166
168
|
def p; cat @time.strftime('%p') end # %p - Meridian indicator (``AM'' or ``PM'')
|
167
|
-
alias :
|
168
|
-
alias :
|
169
|
-
|
169
|
+
alias :AM :p
|
170
|
+
alias :PM :p
|
171
|
+
|
172
|
+
def pm; self.p.down end # lowercase am/pm
|
173
|
+
alias :am :pm
|
174
|
+
|
175
|
+
def xpm; self.xz.xs.pm end # lowercase am/pm without space or leading zero on preceding number
|
176
|
+
alias :xam :xpm
|
170
177
|
|
171
178
|
|
172
179
|
def S; cat @time.strftime('%S') end # %S - Second of the minute (00..60)
|
@@ -230,6 +237,9 @@ class FluidTime
|
|
230
237
|
end
|
231
238
|
end.join(' '))
|
232
239
|
end
|
240
|
+
alias :today :ytt
|
241
|
+
alias :tomorrow :ytt
|
242
|
+
alias :yesterday :ytt
|
233
243
|
|
234
244
|
def down
|
235
245
|
set(@build.split.tap {|parts| parts << parts.pop.downcase}.join(' '))
|
@@ -247,6 +257,8 @@ class FluidTime
|
|
247
257
|
end.join(' '))
|
248
258
|
end
|
249
259
|
alias :xz :strip_zero
|
260
|
+
alias :x0 :strip_zero
|
261
|
+
alias :nozero :strip_zero
|
250
262
|
|
251
263
|
def strip
|
252
264
|
@build.strip! unless @last_was_space
|
data/spec/fluid-time_spec.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe "FluidTime" do
|
4
|
+
|
4
5
|
it "runs the demo" do
|
5
6
|
FluidTime.demo.should be_nil
|
6
7
|
end
|
@@ -14,4 +15,23 @@ describe "FluidTime" do
|
|
14
15
|
FluidTime.new.txt('01').xz.to_s.should eql('1')
|
15
16
|
end
|
16
17
|
|
18
|
+
it "replaces today's date with Today" do
|
19
|
+
FluidTime.new.date.today.to_s.should match /Today/
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'initialization' do
|
23
|
+
it "accepts just a time" do
|
24
|
+
FluidTime.new('3pm HA!!!').hour.xpm.to_s.should == '3pm'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "accepts date as a string" do
|
28
|
+
FluidTime.new('2012/01/05').date.to_s.should == '01/05/2012'
|
29
|
+
FluidTime.new('2012-01-05').date.to_s.should == '01/05/2012'
|
30
|
+
FluidTime.new('01/05/2012').date.to_s.should == '01/05/2012'
|
31
|
+
FluidTime.new('jan 5th 2012').date.to_s.should == '01/05/2012'
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
|
17
37
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluid-time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Steve Lawson
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-09-05 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|