ruby_weekdays 0.1.0
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/lib/core_ext/date.rb +27 -0
- data/lib/ruby_weekdays.rb +2 -0
- metadata +48 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
class Date
|
2
|
+
def next_weekday
|
3
|
+
return self + (8 - self.wday) if self.friday? || self.saturday?
|
4
|
+
self + 1
|
5
|
+
end
|
6
|
+
|
7
|
+
def previous_weekday
|
8
|
+
return self - (2 + self.wday) if self.sunday? || self.monday?
|
9
|
+
self - 1
|
10
|
+
end
|
11
|
+
|
12
|
+
def weekday?
|
13
|
+
!weekend?
|
14
|
+
end
|
15
|
+
|
16
|
+
def weekend?
|
17
|
+
self.saturday? || self.sunday?
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.next_weekday
|
21
|
+
Date.today.next_weekday
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.previous_weekday
|
25
|
+
Date.today.previous_weekday
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby_weekdays
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Peter Anderson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-16 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description:
|
15
|
+
email:
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/ruby_weekdays.rb
|
21
|
+
- lib/core_ext/date.rb
|
22
|
+
homepage: https://github.com/pete-a/ruby_weekdays
|
23
|
+
licenses: []
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 1.8.24
|
43
|
+
signing_key:
|
44
|
+
specification_version: 3
|
45
|
+
summary: Extends core Date class to allow the selection of upcoming and previous weekdays
|
46
|
+
(e.g Monday-Friday).
|
47
|
+
test_files: []
|
48
|
+
has_rdoc:
|