Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust extension module #101

Merged
merged 26 commits into from
Jul 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
94f31ed
Rust extension module with maturin
ariebovenberg Mar 29, 2024
18a83b4
Make rust extension optional
ariebovenberg Apr 1, 2024
7b81dd6
First classes in rust extension
ariebovenberg Apr 2, 2024
2fc7ccf
Add other datetime types, redesign DateDelta
ariebovenberg Apr 29, 2024
fc2f77f
Improve error handling
ariebovenberg May 20, 2024
a060e69
Add missing methods, improve error handling
ariebovenberg May 28, 2024
7b1d82c
patch up GC/ref handling, 3.13 support
ariebovenberg Jun 10, 2024
5d7ce10
Improve docs, get pure-Python version working again
ariebovenberg Jun 10, 2024
0c39c8c
rationalize method names
ariebovenberg Jun 13, 2024
2e6e53a
fix leftover todos and coverage
ariebovenberg Jun 13, 2024
6cc336c
Fixes for wheels across platforms
ariebovenberg Jun 16, 2024
def6619
fix image link in README
ariebovenberg Jun 19, 2024
3b43929
Additional wheels for other archs
ariebovenberg Jun 19, 2024
a4c0e8f
add flag to see whether rust extension is loaded
ariebovenberg Jun 20, 2024
e5bfa10
additional testing for internal function
ariebovenberg Jun 20, 2024
857caab
add benchmark readme
ariebovenberg Jun 20, 2024
1ef0ab7
docs improvements
ariebovenberg Jun 20, 2024
d517867
small refactorings across extension module
ariebovenberg Jun 20, 2024
9475917
improve robustness of conversions near bounds
ariebovenberg Jun 23, 2024
14876cf
Drop "local" terminolgy from system timezone
ariebovenberg Jun 23, 2024
38cfb27
fix failing tests
ariebovenberg Jun 24, 2024
d93a57f
Replace UTCDateTime with Instant
ariebovenberg Jun 25, 2024
f18b5ba
Rename naive to local, cleanup docs
ariebovenberg Jun 28, 2024
1d4b722
make disambiguate argument required for relevant methods
ariebovenberg Jun 28, 2024
7c35f86
Add ignore_dst and disambiguate arg to relevant methods
ariebovenberg Jun 29, 2024
ce7885a
prepare next release
ariebovenberg Jul 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
additional testing for internal function
  • Loading branch information
ariebovenberg committed Jun 20, 2024
commit e5bfa106532d725b934f4635693a0d1520938930
146 changes: 146 additions & 0 deletions src/naive_datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ impl DateTime {
})
}

// FUTURE: is this actually worth it?
// shift by <48 hours, faster than going through date.shift()
pub(crate) fn small_shift_unchecked(self, secs: i32) -> Self {
debug_assert!(secs.abs() < S_PER_DAY * 2);
let Self { date, time } = self;
Expand Down Expand Up @@ -925,4 +927,148 @@ mod tests {
// invalid date
assert_eq!(parse_date_and_time(b"2023-02-29 02:29:09.123456789"), None);
}

#[test]
fn test_small_shift_unchecked() {
let d = DateTime {
date: Date {
year: 2023,
month: 3,
day: 2,
},
time: Time {
hour: 2,
minute: 9,
second: 9,
nanos: 0,
},
};
assert_eq!(d.small_shift_unchecked(0), d);
assert_eq!(
d.small_shift_unchecked(1),
DateTime {
date: Date {
year: 2023,
month: 3,
day: 2,
},
time: Time {
hour: 2,
minute: 9,
second: 10,
nanos: 0,
}
}
);
assert_eq!(
d.small_shift_unchecked(-1),
DateTime {
date: Date {
year: 2023,
month: 3,
day: 2,
},
time: Time {
hour: 2,
minute: 9,
second: 8,
nanos: 0,
}
}
);
assert_eq!(
d.small_shift_unchecked(S_PER_DAY),
DateTime {
date: Date {
year: 2023,
month: 3,
day: 3,
},
time: Time {
hour: 2,
minute: 9,
second: 9,
nanos: 0,
}
}
);
assert_eq!(
d.small_shift_unchecked(-S_PER_DAY),
DateTime {
date: Date {
year: 2023,
month: 3,
day: 1,
},
time: Time {
hour: 2,
minute: 9,
second: 9,
nanos: 0,
}
}
);
let midnight = DateTime {
date: Date {
year: 2023,
month: 3,
day: 2,
},
time: Time {
hour: 0,
minute: 0,
second: 0,
nanos: 0,
},
};
assert_eq!(midnight.small_shift_unchecked(0), midnight);
assert_eq!(
midnight.small_shift_unchecked(-1),
DateTime {
date: Date {
year: 2023,
month: 3,
day: 1,
},
time: Time {
hour: 23,
minute: 59,
second: 59,
nanos: 0,
}
}
);
assert_eq!(
midnight.small_shift_unchecked(-S_PER_DAY),
DateTime {
date: Date {
year: 2023,
month: 3,
day: 1,
},
time: Time {
hour: 0,
minute: 0,
second: 0,
nanos: 0,
}
}
);
assert_eq!(
midnight.small_shift_unchecked(-S_PER_DAY - 1),
DateTime {
date: Date {
year: 2023,
month: 2,
day: 28,
},
time: Time {
hour: 23,
minute: 59,
second: 59,
nanos: 0,
}
}
);
}
}