datey 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/datey.rb +2 -2
- data/lib/datey/formatter.rb +11 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c021b138f9ffc9f5120511ea6475344f9d5a857
|
4
|
+
data.tar.gz: 9104ed36edc2508bf3528273e6351df06a2b8081
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27a9baed1791e3ff02905d3556372bb1fe1e1ffdf399ccbf90ee1d60a4f0da7e000a853bdf64d4cb8d8db024a9a8b37140c34daf78373751df02e051510d396a
|
7
|
+
data.tar.gz: 8c7a17904134ec19e0d9eda890386c4fae44a44a5d59b4de3b25f3bce688200163d17e9d16fcc292d5942af34156d4c42bdf7ea9f70dc8cdcf3942bae0636bc4
|
data/lib/datey.rb
CHANGED
data/lib/datey/formatter.rb
CHANGED
@@ -4,15 +4,16 @@ require 'datey/interrogator'
|
|
4
4
|
module Datey
|
5
5
|
class Formatter
|
6
6
|
|
7
|
-
def initialize(time)
|
7
|
+
def initialize(time, context = :past)
|
8
8
|
@time = time
|
9
|
+
@context = context
|
9
10
|
end
|
10
11
|
|
11
12
|
#
|
12
13
|
# Return the date and time
|
13
14
|
#
|
14
15
|
def date_and_time
|
15
|
-
"#{date} at #{time}"
|
16
|
+
@time.is_a?(Time) ? "#{date} at #{time}" : date
|
16
17
|
end
|
17
18
|
|
18
19
|
#
|
@@ -36,11 +37,15 @@ module Datey
|
|
36
37
|
"Yesterday"
|
37
38
|
elsif interrogator.tomorrow?
|
38
39
|
"Tomorrow"
|
39
|
-
elsif interrogator.
|
40
|
-
|
41
|
-
elsif interrogator.
|
40
|
+
elsif @context == :future && interrogator.next_x_days?(6)
|
41
|
+
name_of_day
|
42
|
+
elsif @context == :future && interrogator.next_week?
|
43
|
+
"Next #{name_of_day}"
|
44
|
+
elsif @context == :past && interrogator.last_x_days?(6)
|
42
45
|
name_of_day
|
43
|
-
elsif interrogator.
|
46
|
+
elsif @context == :past && interrogator.last_x_days?(12)
|
47
|
+
"Last #{name_of_day}"
|
48
|
+
elsif @context == :past && interrogator.next_x_days?(6)
|
44
49
|
"Next #{name_of_day}"
|
45
50
|
else
|
46
51
|
string = "#{name_of_day} #{day_of_month} #{name_of_month}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Ruby library for formatting & interrogating dates & times
|
14
14
|
email:
|