ifc_date 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/README.md +49 -0
- data/lib/ifc_date/class_methods.rb +2 -0
- data/lib/ifc_date/version.rb +1 -1
- data/lib/ifc_date.rb +0 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6979a62fb8321d9418b5789cc02303e536abcc042350412d538158b979370557
|
4
|
+
data.tar.gz: aa6d5344f97499fc6f173ba790a615e76507a092eec2b8b3d5af8b0f9af1cb05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51e4513597bc76020664126c47fac826e56f048a16ec74897d4afe9f07d38f14b4c856567ebf5e2bc537ad1d8d0bed7f92d3d012473def43f2c0cd7973e0ef7f
|
7
|
+
data.tar.gz: 5ff49d42a1b8cb58e552617b2ecce0a85341490932e273a24b85a462368b5c3b4e3249c832a7f99307bf9b01daf2ac07d90ee4cc3fb9da21f750368739f31b0d
|
data/README.md
CHANGED
@@ -33,6 +33,55 @@ or from a standard `Date` object
|
|
33
33
|
Date.today.ifc
|
34
34
|
```
|
35
35
|
|
36
|
+
### Concepts
|
37
|
+
It is really important to know how the indices of the different time units are:
|
38
|
+
|
39
|
+
#### starday?
|
40
|
+
```ruby
|
41
|
+
ifc_date.starday?
|
42
|
+
```
|
43
|
+
This is a concept introduced in this project. Since there is already a Moonday and a Sunday,
|
44
|
+
The intermittant days, Year day and Leap day can be called Starday, it works in the code.
|
45
|
+
|
46
|
+
#### day_of_year, yday
|
47
|
+
```ruby
|
48
|
+
ifc_date.day_of_year # alias ifc_date.yday
|
49
|
+
```
|
50
|
+
This is the day of the year, ranges from 1-365 for non leap year, 1-366 for leap year.
|
51
|
+
|
52
|
+
#### day_of_week, wday
|
53
|
+
```ruby
|
54
|
+
ifc_date.day_of_week # alias ifc_date.wday
|
55
|
+
```
|
56
|
+
This is the day of the week. Ranges from 0-6, Indicating Sunday-Saturday.
|
57
|
+
There is no days starting on Monday concept.
|
58
|
+
When it is Starday a 7 will be returned.
|
59
|
+
This will work in the `ifc_date.day_name` and `ifc_date.abbr_day_name` methods
|
60
|
+
|
61
|
+
#### week_of_year, week
|
62
|
+
```ruby
|
63
|
+
ifc_date.week_of_year # alias ifc_date.week
|
64
|
+
```
|
65
|
+
This returns the number of the week of the year. Ranges from 1-52. Note that the legacy date system
|
66
|
+
can have week numbers 53 both in December and Januari, this will be the past.
|
67
|
+
|
68
|
+
At the moment on a Starday the week number will return 0. Personally I might prefer to add the
|
69
|
+
Starday week\_of\_year number to the week number that preceeds it. But I still have to
|
70
|
+
investigate the validity of this one based on the specs.
|
71
|
+
|
72
|
+
#### day_of_month, mday
|
73
|
+
```ruby
|
74
|
+
ifc_date.day_of_month # alias ifc_date.mday
|
75
|
+
```
|
76
|
+
This returns the index of the day in the month. Ranges 1-28
|
77
|
+
|
78
|
+
#### month_of_year, month
|
79
|
+
```ruby
|
80
|
+
ifc_date.month_of_year # alias ifc_date.month
|
81
|
+
```
|
82
|
+
This returns the index of the month in the year. Ranges 1-13.
|
83
|
+
The Starday days are added to the month number that preceeds those days as day number 29.
|
84
|
+
|
36
85
|
## Development
|
37
86
|
|
38
87
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -5,6 +5,8 @@ module IfcDateClassMethods
|
|
5
5
|
(year % 400).zero?
|
6
6
|
end
|
7
7
|
|
8
|
+
# Do not execute computational expensive operations more than once.
|
9
|
+
# NOTE: only use for explicitly non nil return methods, false is fine
|
8
10
|
def memoize(method_name)
|
9
11
|
unmemoized_name = "_unmemoized_#{method_name}"
|
10
12
|
instance_var_name = method_name.end_with?('?') ? "@is_#{method_name[0..-2]}" : "@#{method_name}"
|
data/lib/ifc_date/version.rb
CHANGED
data/lib/ifc_date.rb
CHANGED