ifc_date 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89ca22bbc889e7505098ed029e28ddde175726a4405e656db1562efecd0fd1dc
4
- data.tar.gz: 240078f8a04ed2f6c2ba24f5d61417435824443008ec40719a92e5ac186d5f5c
3
+ metadata.gz: 6979a62fb8321d9418b5789cc02303e536abcc042350412d538158b979370557
4
+ data.tar.gz: aa6d5344f97499fc6f173ba790a615e76507a092eec2b8b3d5af8b0f9af1cb05
5
5
  SHA512:
6
- metadata.gz: ba2e63ce4cb6e4600069b57479d800b9b20368046c3d3535aece77e4559aeb6c278f2540e11bd7cb0646e34322b4acff6bc2260ad67c6349b48f3d3e74dd6296
7
- data.tar.gz: f796584f34048013d885d9449a3411ace6c5790fa66d53530366f8fc2812e03ca1f5e56214c379674746ff2d465077f40d992589c26105428ec51c78b1bdd3c7
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}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class IfcDate
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/ifc_date.rb CHANGED
@@ -73,8 +73,6 @@ class IfcDate
73
73
 
74
74
  def day_of_month
75
75
  return 29 if starday?
76
- #remainder = day_of_year_divmod_twenty_eight[1]
77
- #remainder.zero? ? 28 : remainder
78
76
  day_of_year_divmod_twenty_eight[1] + 1
79
77
  end
80
78
  alias mday day_of_month
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ifc_date
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin ter Kuile