week 0.0.1 → 0.0.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 +14 -1
- data/lib/week.rb +6 -12
- metadata +7 -5
data/README.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
-
|
1
|
+
=== Description:
|
2
|
+
A simple gem to work with weeks as arrays of days numbers. It works with commercial dates (according to http://en.wikipedia.org/wiki/ISO_week_date).
|
3
|
+
|
4
|
+
=== Usage:
|
5
|
+
|
6
|
+
week(2011, 52).map { |day| p day }
|
7
|
+
# =>
|
8
|
+
# Sun Dec 25 00:00:00 +0200 2011
|
9
|
+
# Mon Dec 26 00:00:00 +0200 2011
|
10
|
+
# Tue Dec 27 00:00:00 +0200 2011
|
11
|
+
# Wed Dec 28 00:00:00 +0200 2011
|
12
|
+
# Thu Dec 29 00:00:00 +0200 2011
|
13
|
+
# Fri Dec 30 00:00:00 +0200 2011
|
14
|
+
# Sat Dec 31 00:00:00 +0200 2011
|
2
15
|
|
3
16
|
Copyright (c) 2011 Sergey Gerasimov
|
data/lib/week.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
1
|
require 'date'
|
3
2
|
|
3
|
+
# Simple addition for days-processing simplification
|
4
4
|
class Numeric
|
5
5
|
def days
|
6
6
|
self * 60 * 60 * 24
|
@@ -17,9 +17,7 @@
|
|
17
17
|
|
18
18
|
class << self
|
19
19
|
def nmonth year
|
20
|
-
|
21
|
-
nmonth[1] = Date.new(year, 1, 1).leap? ? 29 : 28
|
22
|
-
nmonth
|
20
|
+
[31, (Date.new(year, 1, 1).leap? ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
@@ -36,7 +34,7 @@
|
|
36
34
|
common_days += month
|
37
35
|
end
|
38
36
|
|
39
|
-
tmp_first_day = tmp_wday - common_days
|
37
|
+
tmp_first_day = tmp_wday - common_days
|
40
38
|
|
41
39
|
# fixing day number for calculate first week of the year
|
42
40
|
tmp_first_day = tmp_first_day == 0 ? 1 : tmp_first_day
|
@@ -59,12 +57,8 @@
|
|
59
57
|
end
|
60
58
|
end
|
61
59
|
|
62
|
-
#
|
63
|
-
|
60
|
+
# Simplier API for Week class usage
|
61
|
+
@today = Date.today
|
62
|
+
def week(year = @today.year, week = @today.cweek, fday = 0)
|
64
63
|
Week.new(year, week, fday).days
|
65
64
|
end
|
66
|
-
|
67
|
-
#Week(2011, 1).map do |day|
|
68
|
-
# p day
|
69
|
-
#end
|
70
|
-
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: week
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sergey Gerasimov
|
@@ -15,7 +15,8 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-08-10 00:00:00 +03:00
|
19
|
+
default_executable:
|
19
20
|
dependencies: []
|
20
21
|
|
21
22
|
description: Simple gem to work with weeks as arrays of day numbers.
|
@@ -32,6 +33,7 @@ files:
|
|
32
33
|
- CHANGELOG.md
|
33
34
|
- LICENSE
|
34
35
|
- lib/week.rb
|
36
|
+
has_rdoc: true
|
35
37
|
homepage: http://github.com/grsmv/week
|
36
38
|
licenses: []
|
37
39
|
|
@@ -61,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
63
|
requirements: []
|
62
64
|
|
63
65
|
rubyforge_project: week
|
64
|
-
rubygems_version: 1.
|
66
|
+
rubygems_version: 1.4.2
|
65
67
|
signing_key:
|
66
68
|
specification_version: 3
|
67
69
|
summary: Simple gem to work with weeks as arrays of day numbers.
|