Content
Updated by Sebastian Fiedlschuster over 1 year ago
Pull Request: [https://github.com/opf/openproject/pull/11678](https://github.com/opf/openproject/pull/11678)
### Timestamps
For the baseline-comparison feature we need to query historic data of work packages. In addition to the current state of the work packages (today), we can ask for the state of work packages at other points in time (**timestamps**).
The timestamps can be specified
* **absolute**, e.g. "2022-08-01", or
* **relative**, e.g. "1 month ago".
This pull request implements an abstraction class `Timestamp` that can be initialised with [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) strings.
```ruby
absolute_timestamp = Timestamp.parse("2022-10-29T23:01:23Z")
relative_timestamp = Timestamp.parse("P-5Y") # 5 years ago
```
The timestamps can be converted to regular times, which are always absolute then:
```ruby
relative_timestamp.to_time
```
The timestamps can be passed to work package queries:
```ruby
WorkPackage.at_timestamp(relative_timestamp).where(...)
```
### Timestamps
For the baseline-comparison feature we need to query historic data of work packages. In addition to the current state of the work packages (today), we can ask for the state of work packages at other points in time (**timestamps**).
The timestamps can be specified
* **absolute**, e.g. "2022-08-01", or
* **relative**, e.g. "1 month ago".
This pull request implements an abstraction class `Timestamp` that can be initialised with [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) strings.
```ruby
absolute_timestamp = Timestamp.parse("2022-10-29T23:01:23Z")
relative_timestamp = Timestamp.parse("P-5Y") # 5 years ago
```
The timestamps can be converted to regular times, which are always absolute then:
```ruby
relative_timestamp.to_time
```
The timestamps can be passed to work package queries:
```ruby
WorkPackage.at_timestamp(relative_timestamp).where(...)
```