Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • T torque-postgresql
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 6
    • Issues 6
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Carlos
  • torque-postgresql
  • Wiki
  • Date Time Range

Date Time Range · Changes

Page history
Updated Date Time Range (markdown) authored Aug 18, 2019 by Carlos's avatar Carlos
Hide whitespace changes
Inline Side-by-side
Date-Time-Range.md
View page @ 6cdaacbf
......@@ -201,4 +201,50 @@ NOT daterange(LOWER("events"."period")::date),UPPER("events"."period")::date) &&
NOT daterange((LOWER("events"."period") - "events"."interval")::date),(UPPER("events"."period") + "events"."interval")::date) && value
- OR -
NOT daterange((LOWER("events"."period") - "events"."interval")::date),(UPPER("events"."period") + "events"."interval")::date) && daterange(left, right)
```
### Instance methods
A couple of instance methods are provided as well. One of the options is to also use the new provided methods for the [Range](https://github.com/crashtech/torque-postgresql/wiki/Range) class.
#### `:current?` as `.current_period?`
Check if the value on the column represents a current period.
```ruby
(period.min < Time.zone.now && period.max > Time.zone.now) || default
```
#### `:current_on?` as `.current_period_on?(value)`
Similar to the above one, but allowing a valur to be passed.
```ruby
(period.min < value && period.max > value) || default
```
#### `:start` as `.period_start`
Get the beginning of the period.
```ruby
period.min
```
#### `:finish` as `.period_finish`
Get the ending of the period.
```ruby
period.max
```
#### `:real` as `.real_period` **(ONLY WITH THRESHOLD)**
Get the real range period while considering the threshold.
```ruby
((period.min - threshold)..(period.max + threshold))
```
#### `:real_start` as `.period_real_start`
Get the beginning of the period while considering the threshold.
```ruby
period.min - threshold
```
#### `:real_finish` as `.period_real_finish`
Get the ending of the period while considering the threshold.
```ruby
period.max + threshold
```
\ No newline at end of file
Clone repository
  • Wiki
  • Configuring

Core Extensions

  • Range

Data types

  • Enum
  • Enum Set
  • Interval
  • Date/Time Range
  • Box
  • Circle
  • Line
  • Segment

Querying

  • Arel
  • Has Many
  • Belongs to Many
  • Dynamic Attributes
  • Distinct On
  • Auxiliary Statements
  • Inherited Tables