timeboss 1.1.3 → 1.1.4

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: 65f9e2cd955a728e0efd00e99f530f1ff6dbb7ee0c8cee7e25499466fb10edc9
4
- data.tar.gz: 9523e2983ffff0d5d33cf9b07e7fd4cd1b26b54c68e8a3f77d8996aaa7ad991d
3
+ metadata.gz: 17c22a99ae9b02ecc3f435e99622a075c0a26af2d15f87070aefb1e6c0deb1c4
4
+ data.tar.gz: 774b9250575112756f30f9522bd98b36ed017a010cace574407a88b4f3316f98
5
5
  SHA512:
6
- metadata.gz: 1f850961e4659cee0b07e59d4421f1444c39e3882338f5189cd5821e5d4ec00228c4043aef7c001df8a2181cf4161671943653e7e0c843f419f4f7d91b6bb99d
7
- data.tar.gz: 24a8f28844c20caf7f0294a5e5db155ff809f46ad76e421e97d807b929ceca37035d9b89539a5600713d9420ba8f799fa1668c61e47b040a8728c41df12a67df
6
+ metadata.gz: 949de3a932fe24a8c34e8bf9ba89eed605ff6f8148ab5763600a6fb6ec00b822cfc2425b4aebce6982ecc62be43fb037723a264a6543539e626755dc39f1ec04
7
+ data.tar.gz: ac0312302c3e89d193bf16354ccf3593e3bed79e6e569b1580d78f82ad40bf663765f950078c86572d3e245f265047b947dbe70c1948b82bb958b205a73542af
@@ -0,0 +1,70 @@
1
+ # TimeBoss Period Specifiers
2
+ Below is a list of examples for TimeBoss period specifiers. This list is by no means comprehensive, but hopefully serves as a guide to help
3
+ you understand how to communicate with TimeBoss.
4
+
5
+ All specifiers are resolved within the context of the utilized calendar (Gregorian, Broadcast, etc).
6
+
7
+ ## Absolute Periods
8
+ An "absolute" period is one that never changes, regardless of the current date. "December of 2019" always references the same time period,
9
+ regardless of what today is.
10
+
11
+ _Assuming the Broadcast calendar is in use:_
12
+ | Specifier | Description | Resolution |
13
+ | -------------------------- | ----------------------------------- | ----------------------- |
14
+ | `2020Q3` | 3rd quarter of 2020 | 6/29/2020 - 9/27/2020 |
15
+ | `2022M1` | 1st month of 2022 | 12/27/2021 - 1/30/2022 |
16
+ | `2021H1M2` | 2nd month of the first half of 2021 | 2/1/2021 - 2/28/2021 |
17
+ | `2020W40` | 40th week of 2020 | 9/28/2020 - 10/4/2020 |
18
+ | `2027` | 2027 | 12/28/2026 - 12/26/2027 |
19
+ | `1999-07-31` or `19990731` | July 31, 1999 | 7/31/1999 - 7/31/1999 |
20
+
21
+ The sub-identifiers for period granularities are:
22
+ - `D`: day
23
+ - `W`: week
24
+ - `M`: month
25
+ - `Q`: quarter
26
+ - `H`: half
27
+
28
+ ## Relative Periods
29
+ A "relative" period is one that changes based on the current date. "Last week" means something different today than it will a month from now.
30
+
31
+ _Assuming today is April 29, 2022, in the Gregorian calendar:_
32
+ | Specifier | Description | Resolution |
33
+ | --------------- | ----------------------------------- | --------------------- |
34
+ | `last_month` | March 2022 | 3/1/2022 - 3/31/2022 |
35
+ | `this_month-2` | February 2022 | 2/1/2022 - 2/28/2022 |
36
+ | `this_week` | Week of April 25, 2022 | 4/25/2022 - 5/1/2022 |
37
+ | `yesterday` | April 28, 2022 | 4/28/2022 - 4/28/2022 |
38
+ | `today+4` | May 3, 2022 | 5/3/2022 - 5/3/2022 |
39
+ | `next_year` | 2023 | 1/1/2023 - 12/31/2023 |
40
+
41
+ The relative prefixes can be used in conjuction with any period granularity. The terms here should be joined with the underscore (`_`) character as in the examples above.
42
+
43
+ Relative prefixes are:
44
+ - `last`
45
+ - `this`
46
+ - `next`
47
+
48
+ Period granularities are:
49
+ - `day`
50
+ - `week`
51
+ - `month`
52
+ - `quarter`
53
+ - `half`
54
+ - `year`
55
+
56
+ Accepted single-day specifiers:
57
+ - `yesterday`
58
+ - `today`
59
+ - `tomorrow`
60
+
61
+ ## Compound Periods
62
+ Absolute and/or relative periods can be combined together to build "compound" periods by utilizing TimeBoss' "range" operator (`..`):
63
+
64
+ _Assuming today is April 29, 2022, in the Gregorian calendar:_
65
+ | Specifier | Description | Resolution |
66
+ | -------------------------- | ------------------------------------------------------------------------ | --------------------- |
67
+ | `yesterday..today` | Yesterday and Today | 4/28/2022 - 4/29/2022 |
68
+ | `last_quarter..this_month` | From the first day of last quarter, through the end of the current month | 1/1/2022 - 4/30/2022 |
69
+ | `this_week-2..next_week` | From the first day of 2 weeks ago, through the last day of next week | 4/11/2022 - 5/8/2022 |
70
+ | `2022M2..this_year` | From the first day of February, through the last day of this year | 2/1/2022 - 12/31/2022 |
data/README.md CHANGED
@@ -25,7 +25,7 @@ $ gem install timeboss
25
25
  ```
26
26
 
27
27
  ## Usage
28
- Supports `year`, `half`, `quarter`, `month`, `week` (non-gregorian calendars only), and `day`.
28
+ Supports `year`, `half`, `quarter`, `month`, `week`, and `day`.
29
29
 
30
30
  Prepare your calendar for use:
31
31
 
@@ -1,3 +1,4 @@
1
+ require "./lib/timeboss"
1
2
  require "./lib/timeboss/calendars"
2
3
 
3
4
  namespace :timeboss do
@@ -15,6 +15,7 @@ module TimeBoss
15
15
  end
16
16
 
17
17
  define_method "#{type}_for" do |date|
18
+ date = date.to_date
18
19
  window = public_send(type, date.year - 1, 1)
19
20
  loop do
20
21
  break window if window.to_range.include?(date)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TimeBoss
4
- VERSION = "1.1.3"
4
+ VERSION = "1.1.4"
5
5
  end
data/lib/timeboss.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support"
4
+ require "active_support/all"
4
5
  require "timeboss/version"
5
6
 
6
7
  # TimeBoss
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timeboss
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin McDonald
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-22 00:00:00.000000000 Z
11
+ date: 2022-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -184,6 +184,7 @@ files:
184
184
  - CODE_OF_CONDUCT.md
185
185
  - Gemfile
186
186
  - LICENSE.txt
187
+ - PERIOD_SPECIFIERS.md
187
188
  - README.md
188
189
  - Rakefile
189
190
  - bin/tbsh