fluid-time 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,15 @@
1
- # April 12, 2012 @ 09:22 AM PDT
2
- ```ruby
3
- FluidTime.new('2012/04/12 9:22').month.day.th.sc.ss.year.txt('@').time.xz.pm.zone.to_s
4
- ```
1
+ # FluidTime Changelog
2
+
3
+ ## [0.2.1] April 11th, 2012 @ 1:38pm PDT
4
+ FluidTime.new('2012/04/11 13:38').month.day.th.sc.ss.year.txt('@').time.xz.xs.pm.down.zone.to_s
5
+
6
+ - Documentation improvements
7
+ - Re-order elements in FluidTime.demo
8
+ - Removed dashes and colons from the .db preset
9
+ - Remove reliance on Date.tomorrow and Date.yesterday (was broken without rails)
10
+
11
+ # [0.1.x] April 10th, 2012 @ 21:22 PM PDT
12
+ FluidTime.new('2012/04/10 21:22').month.day.th.sc.ss.year.txt('@').time.xz.pm.zone.to_s
5
13
 
6
14
  Making it ready for the first release:
7
15
 
@@ -0,0 +1,82 @@
1
+ # FluidTime
2
+
3
+ Stop formatting time like a C-anderthal. Craft human readable time formats like building a sentence.
4
+
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
+ # "April 10th, 2012 @ 9:22pm PDT"
7
+
8
+ Strip zeros, ordinalize, and change case with ease:
9
+
10
+ FluidTime.new.time.pm.zone.to_s
11
+ # 09:51:29 PM PDT
12
+
13
+ FluidTime.new.time.xz.xs.pm.down.zone.to_s
14
+ # 9:51:51pm PDT
15
+
16
+ FluidTime.new.date.hour.colon.min.ytt.xs.pm.down.to_s
17
+ # 04/11/2012 01:46pm
18
+
19
+ FluidTime.new.date.hour.colon.min.ytt.xs.pm.down.to_s # ytt - replaces date with yesterday, today, tomorrow
20
+ # Today 01:45pm
21
+
22
+ Remember to end your chains with .to_s or use interpolation "Today is #{FluidTime.new.weekday.upper}"
23
+
24
+ FluidTime.demo
25
+
26
+ # FluidTime.new. to_time.to_s Wed Apr 11 13:47:35 -0700 2012
27
+ # FluidTime.new. to_date.to_s 2012-04-11
28
+ # FluidTime.new. a.ddd.wday.to_s Wed Wed Wed
29
+ # FluidTime.new. A.tday.weekday.to_s Wednesday Wednesday Wednesday
30
+ # FluidTime.new. b.mmm.smonth.to_s Apr Apr Apr
31
+ # FluidTime.new. B.month.to_s April April
32
+ # FluidTime.new. c.to_s Wed Apr 11 13:47:35 2012
33
+ # FluidTime.new. full.to_s Wed Apr 11 13:47:35 2012
34
+ # FluidTime.new. d.dd.day.num.to_s 11 11 11 11
35
+ # FluidTime.new. e.mday.to_s 11 11
36
+ # FluidTime.new. H.h24.mhour.hour24.to_s 13 13 13 13
37
+ # FluidTime.new. I.h12.hour.hour12.to_s 01 01 01 01
38
+ # FluidTime.new. l.to_s 1
39
+ # FluidTime.new. j.yday.day_of_year.to_s 102 102 102
40
+ # FluidTime.new. m.mm.mon.month_of_year.to_s 04 04 04 04
41
+ # FluidTime.new. M.min.minute.to_s 47 47 47
42
+ # FluidTime.new. p.am.pm.to_s PM PM PM
43
+ # FluidTime.new. S.sec.second.to_s 35 35 35
44
+ # FluidTime.new. U.to_s 15
45
+ # FluidTime.new. W.to_s 15
46
+ # FluidTime.new. w.to_s 3
47
+ # FluidTime.new. x.autodate.to_s 04/11/12 04/11/12
48
+ # FluidTime.new. X.autotime.to_s 13:47:35 13:47:35
49
+ # FluidTime.new. y.yy.sy.to_s 12 12 12
50
+ # FluidTime.new. Y.year.to_s 2012 2012
51
+ # FluidTime.new. Z.zone.timezone.to_s PDT PDT PDT
52
+ # FluidTime.new. date.to_s 04/11/2012
53
+ # FluidTime.new. time.to_s 01:47:35
54
+ # FluidTime.new. db.to_s 2012-04-11 13:01:35
55
+ # FluidTime.new. usdate.to_s 04/11/2012
56
+ # FluidTime.new. W.th.comma.space._('min').to_s 15th, min
57
+ # FluidTime.new. date.hour.colon.min.ytt.pm.to_s Today 01:47 PM
58
+ # FluidTime.new. year.mmm.d.th.to_s 2012 Apr 11th
59
+ # FluidTime.new. time.xs.p.down.to_s 01:47:35pm
60
+ # FluidTime.new. txt('01').xz.to_s 1
61
+ # FluidTime.new. txt('1:00').xz.xs.pm.lower.zone.to_s 1pm PDT
62
+ # FluidTime.new. _('braces').lb.lp.lc.rc.rp.rb.to_s braces[({})]
63
+ # FluidTime.new. _('symbols').lb.tp.ts.tc.ts.tn.ts.td.rb.to_s symbols[. , : -]
64
+ # FluidTime.new. _('symbols').lb.sp.ss.sc.ss.sn.ss.sd.rb.to_s symbols[. , : -]
65
+ # FluidTime.new. period.space.comma.to_s . ,
66
+ # FluidTime.new. colon.space.dash.space.slash.to_s : - /
67
+
68
+
69
+ # Contributing to fluid-time
70
+
71
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
72
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
73
+ * Fork the project.
74
+ * Start a feature/bugfix branch.
75
+ * Commit and push until you are happy with your contribution.
76
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
77
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
78
+
79
+ # Copyright
80
+
81
+ Copyright (c) 2012 Steve Lawson. See LICENSE.txt for further details.
82
+
data/Rakefile CHANGED
@@ -18,10 +18,11 @@ Jeweler::Tasks.new do |gem|
18
18
  gem.homepage = "http://github.com/smlsml/fluid-time"
19
19
  gem.license = "MIT"
20
20
  gem.summary = %Q{A fluent interface for formatting ruby time}
21
- gem.description = %Q{Stop formatting time like a C-anderthal. Craft human readable time formats like building a sentence.\n
22
- \n> FluidTime.new('2012/04/12 9:22').month.day.th.sc.ss.year.txt('@').time.xz.pm.zone.to_s
23
- \n# April 12th, 2012 @ 09:22 AM PDT
24
- }
21
+ gem.description = <<-TXT
22
+ Stop formatting time like a C-anderthal. Craft human readable time formats like building a sentence.
23
+ > FluidTime.new('2012/04/10 21:22').month.day.th.comma.space.xs.year.txt('@').time.xz.xs.pm.lower.zone.to_s
24
+ => "April 10th, 2012 @ 9:22pm PDT"
25
+ TXT
25
26
  gem.email = "smlsml@gmail.com"
26
27
  gem.authors = ["Steve Lawson"]
27
28
  # dependencies defined in Gemfile
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -5,22 +5,19 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fluid-time}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
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
12
  s.date = %q{2012-04-11}
13
13
  s.description = %q{Stop formatting time like a C-anderthal. Craft human readable time formats like building a sentence.
14
-
15
-
16
- > FluidTime.new('2012/04/12 9:22').month.day.th.sc.ss.year.txt('@').time.xz.pm.zone.to_s
17
-
18
- # April 12th, 2012 @ 09:22 AM PDT
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
+ => "April 10th, 2012 @ 9:22pm PDT"
19
16
  }
20
17
  s.email = %q{smlsml@gmail.com}
21
18
  s.extra_rdoc_files = [
22
19
  "LICENSE.txt",
23
- "README.rdoc"
20
+ "README.md"
24
21
  ]
25
22
  s.files = [
26
23
  ".document",
@@ -28,7 +25,7 @@ Gem::Specification.new do |s|
28
25
  "CHANGELOG.md",
29
26
  "Gemfile",
30
27
  "LICENSE.txt",
31
- "README.rdoc",
28
+ "README.md",
32
29
  "Rakefile",
33
30
  "VERSION",
34
31
  "fluid-time.gemspec",
@@ -17,41 +17,45 @@ class FluidTime
17
17
  %w{
18
18
  to_time
19
19
  to_date
20
+ a.ddd.wday
20
21
  A.tday.weekday
21
- weekday.up
22
22
  b.mmm.smonth
23
23
  B.month
24
24
  c
25
25
  full
26
- d.day.num.dd
26
+ d.dd.day.num
27
27
  e.mday
28
- mmm.d.th.year
29
- year.mmm.d.th
30
- H.h24.hour24
28
+ H.h24.mhour.hour24
31
29
  I.h12.hour.hour12
32
30
  l
33
31
  j.yday.day_of_year
34
32
  m.mm.mon.month_of_year
35
33
  M.min.minute
36
34
  p.am.pm
37
- time.xs.p.down
38
35
  S.sec.second
39
- U.th.txt('week')
40
- W.th.tc.ts._('min')
36
+ U
37
+ W
41
38
  w
42
39
  x.autodate
43
40
  X.autotime
44
- date
45
- time
46
41
  y.yy.sy
47
42
  Y.year
48
43
  Z.zone.timezone
44
+ date
45
+ time
46
+ db
47
+ usdate
48
+ W.th.comma.space._('week')
49
+ date.hour.colon.min.ytt.pm
50
+ year.mmm.d.th
51
+ time.xs.p.down
49
52
  txt('01').xz
50
53
  txt('1:00').xz.xs.pm.lower.zone
51
54
  _('braces').lb.lp.lc.rc.rp.rb
52
55
  _('symbols').lb.tp.ts.tc.ts.tn.ts.td.rb
53
56
  _('symbols').lb.sp.ss.sc.ss.sn.ss.sd.rb
54
- db
57
+ period.space.comma
58
+ colon.space.dash.space.slash
55
59
  }.each {|ex| "FluidTime.new. #{ex}.to_s".tap {|str| p str + (" %#{80 - str.length}s" % eval(str))} }
56
60
  nil
57
61
  end
@@ -100,8 +104,8 @@ class FluidTime
100
104
 
101
105
 
102
106
  def A; cat @time.strftime('%A') end # %A - The full weekday name (``Sunday'')
103
- alias :weekday :A
104
107
  alias :tday :A
108
+ alias :weekday :A
105
109
 
106
110
 
107
111
  def b; cat @time.strftime('%b') end # %b - The abbreviated month name (``Jan'')
@@ -129,7 +133,7 @@ class FluidTime
129
133
 
130
134
  def H; cat @time.strftime('%H') end # %H - Hour of the day, 24-hour clock (00..23)
131
135
  alias :h24 :H # use h24.xz to remove leading zero
132
- alias :hour :H
136
+ alias :mhour :H
133
137
  alias :hour24 :H
134
138
 
135
139
 
@@ -221,8 +225,8 @@ class FluidTime
221
225
  parts.each_with_index do |part, index|
222
226
  date = Date.parse(part) rescue nil
223
227
  parts[index] = 'Today' if date.is_a?(Date) && date.to_s == Date.today.to_s
224
- parts[index] = 'Tomorrow' if date.is_a?(Date) && date.to_s == Date.tomorrow.to_s
225
- parts[index] = 'Yesterday' if date.is_a?(Date) && date.to_s == Date.yesterday.to_s
228
+ parts[index] = 'Tomorrow' if date.is_a?(Date) && date.to_s == (Date.today + 1).to_s
229
+ parts[index] = 'Yesterday' if date.is_a?(Date) && date.to_s == (Date.today - 1).to_s
226
230
  end
227
231
  end.join(' '))
228
232
  end
@@ -273,7 +277,7 @@ class FluidTime
273
277
  ##### Presets
274
278
 
275
279
  def db
276
- self.Y.dash.m.dash.d.H.colon.I.colon.S
280
+ self.Y.m.d.H.I.S
277
281
  end
278
282
 
279
283
  def usdate
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: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Steve Lawson
@@ -97,11 +97,8 @@ dependencies:
97
97
  name: rcov
98
98
  description: |
99
99
  Stop formatting time like a C-anderthal. Craft human readable time formats like building a sentence.
100
-
101
-
102
- > FluidTime.new('2012/04/12 9:22').month.day.th.sc.ss.year.txt('@').time.xz.pm.zone.to_s
103
-
104
- # April 12th, 2012 @ 09:22 AM PDT
100
+ > FluidTime.new('2012/04/10 21:22').month.day.th.comma.space.xs.year.txt('@').time.xz.xs.pm.lower.zone.to_s
101
+ => "April 10th, 2012 @ 9:22pm PDT"
105
102
 
106
103
  email: smlsml@gmail.com
107
104
  executables: []
@@ -110,14 +107,14 @@ extensions: []
110
107
 
111
108
  extra_rdoc_files:
112
109
  - LICENSE.txt
113
- - README.rdoc
110
+ - README.md
114
111
  files:
115
112
  - .document
116
113
  - .rspec
117
114
  - CHANGELOG.md
118
115
  - Gemfile
119
116
  - LICENSE.txt
120
- - README.rdoc
117
+ - README.md
121
118
  - Rakefile
122
119
  - VERSION
123
120
  - fluid-time.gemspec
@@ -1,75 +0,0 @@
1
- == FluidTime
2
-
3
- Stop formatting time like a C-anderthal. Craft human readable time formats like building a sentence.
4
-
5
- FluidTime.new.month.hour.colon.minute.colon.second
6
- FluidTime.new(Date.today).weekday.month.year
7
- FluidTime.new('04/05/2012 09:45:23').weekday.month.year
8
-
9
- Do things like strip zeros, ordinalize and change case with ease (ordinalize only works if you've included rails for now)
10
-
11
-
12
- FluidTime.new.time.pm.zone.to_s
13
- # 09:51:29 PM PDT
14
-
15
- FluidTime.new.time.xz.xs.pm.down.zone.to_s
16
- # 9:51:51pm PDT
17
-
18
-
19
- REMEMBER to end your chains with .to_s or use in a string "Today is #{FluidTime.new.weekday.upper}"
20
-
21
- FluidTime.demo
22
-
23
- # FluidTime.new. to_time.to_s Tue Apr 10 21:46:11 -0700 2012
24
- # FluidTime.new. to_date.to_s 2012-04-10
25
- # FluidTime.new. A.tday.weekday.to_s Tuesday Tuesday Tuesday
26
- # FluidTime.new. weekday.up.to_s TUESDAY
27
- # FluidTime.new. b.mmm.smonth.to_s Apr Apr Apr
28
- # FluidTime.new. B.month.to_s April April
29
- # FluidTime.new. c.to_s Tue Apr 10 21:46:11 2012
30
- # FluidTime.new. full.to_s Tue Apr 10 21:46:11 2012
31
- # FluidTime.new. d.day.num.dd.to_s 10 10 10 10
32
- # FluidTime.new. e.mday.to_s 10 10
33
- # FluidTime.new. mmm.d.th.year.to_s Apr 10 2012
34
- # FluidTime.new. year.mmm.d.th.to_s 2012 Apr 10
35
- # FluidTime.new. H.h24.hour24.to_s 21 21 21
36
- # FluidTime.new. I.h12.hour.hour12.to_s 09 09 09 09
37
- # FluidTime.new. l.to_s 9
38
- # FluidTime.new. j.yday.day_of_year.to_s 101 101 101
39
- # FluidTime.new. m.mm.mon.month_of_year.to_s 04 04 04 04
40
- # FluidTime.new. M.min.minute.to_s 46 46 46
41
- # FluidTime.new. p.am.pm.to_s PM PM PM
42
- # FluidTime.new. time.xs.p.down.to_s 09:46:11pm
43
- # FluidTime.new. S.sec.second.to_s 11 11 11
44
- # FluidTime.new. U.th.txt('week').to_s 15 week
45
- # FluidTime.new. W.th.tc.ts._('min').to_s 15, min
46
- # FluidTime.new. w.to_s 2
47
- # FluidTime.new. x.autodate.to_s 04/10/12 04/10/12
48
- # FluidTime.new. X.autotime.to_s 21:46:11 21:46:11
49
- # FluidTime.new. date.to_s 04/10/2012
50
- # FluidTime.new. time.to_s 09:46:11
51
- # FluidTime.new. y.yy.sy.to_s 12 12 12
52
- # FluidTime.new. Y.year.to_s 2012 2012
53
- # FluidTime.new. Z.zone.timezone.to_s PDT PDT PDT
54
- # FluidTime.new. txt('01').xz.to_s 1
55
- # FluidTime.new. txt('1:00').xz.xs.pm.lower.zone.to_s 1pm PDT
56
- # FluidTime.new. _('braces').lb.lp.lc.rc.rp.rb.to_s braces[({})]
57
- # FluidTime.new. _('symbols').lb.tp.ts.tc.ts.tn.ts.td.rb.to_s symbols[. , : -]
58
- # FluidTime.new. _('symbols').lb.sp.ss.sc.ss.sn.ss.sd.rb.to_s symbols[. , : -]
59
- # FluidTime.new. db.to_s 2012-04-10 21:09:11
60
-
61
- == Contributing to fluid-time
62
-
63
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
64
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
65
- * Fork the project.
66
- * Start a feature/bugfix branch.
67
- * Commit and push until you are happy with your contribution.
68
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
69
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
70
-
71
- == Copyright
72
-
73
- Copyright (c) 2012 Steve Lawson. See LICENSE.txt for
74
- further details.
75
-