Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Added support to add an interval to a timestamp #417

Merged
merged 1 commit into from
Sep 17, 2021
Merged

Conversation

jorgecarleitao
Copy link
Owner

@jorgecarleitao jorgecarleitao commented Sep 17, 2021

This adds support for adding an interval to a timestamp with timezone, thus taking leap days (Feb 29th) and leap hours (daylight saving) into account.

This brings the last missing piece to fully support timestamps with timezones: we can now convert them from and to strings, and perform basic interval arithmetic taking the timezone into account.

3 examples:

  • adding 1 hour to 2020-03-29 00:00:00 WET results in 2020-03-29 02:00:00 WEST
  • adding 7 months and 1 hour to 2020-03-29 00:00:00 WET results in 2020-10-29 01:00:00 WET

the former crosses one summer time shift (and thus adds an extra hour), the latter crosses both (and thus adds no extra hour).

  • adding 1d,1h,1m to 1972-02-28 01:00:00 +01:00 results in 1972-02-29 02:01:00 +01:00

because 1972 has a leap year.

When the timestamp has no timezone information, days are 24 * 60 * 60.

Closes #23

@jorgecarleitao jorgecarleitao added the feature A new feature label Sep 17, 2021
@codecov
Copy link

codecov bot commented Sep 17, 2021

Codecov Report

Merging #417 (bdb6856) into main (d5cc0db) will decrease coverage by 0.08%.
The diff coverage is 56.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #417      +/-   ##
==========================================
- Coverage   80.96%   80.88%   -0.09%     
==========================================
  Files         347      347              
  Lines       22201    22276      +75     
==========================================
+ Hits        17976    18018      +42     
- Misses       4225     4258      +33     
Impacted Files Coverage Δ
src/compute/cast/primitive_to.rs 83.67% <0.00%> (+1.12%) ⬆️
src/compute/arithmetics/time.rs 87.78% <15.38%> (-9.71%) ⬇️
src/compute/arithmetics/mod.rs 49.64% <16.66%> (-1.49%) ⬇️
src/compute/temporal.rs 85.98% <50.00%> (+2.19%) ⬆️
src/temporal_conversions.rs 75.35% <53.06%> (-8.81%) ⬇️
src/array/display.rs 61.15% <72.72%> (-0.55%) ⬇️
tests/it/temporal_conversions.rs 100.00% <100.00%> (ø)
src/types/mod.rs 29.20% <0.00%> (+0.88%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d5cc0db...bdb6856. Read the comment docs.

@jorgecarleitao
Copy link
Owner Author

cc @sundy-li @ritchie46 since I saw you both working with interval arithmetics recently ^_^

@jorgecarleitao jorgecarleitao changed the title Added support to add an interval to a timestamp with timezone. Added support to add an interval to a timestamp Sep 17, 2021
@jorgecarleitao jorgecarleitao merged commit 4701f10 into main Sep 17, 2021
@jorgecarleitao jorgecarleitao deleted the interval_add branch September 17, 2021 22:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate how to add support for timezones in timestamp
1 participant