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

refactoring DateTime(f64) to DateTime(ExcelDateTime) #394

Merged
merged 6 commits into from
Jan 16, 2024

Conversation

dimastbk
Copy link
Contributor

Hi!

This PR introduces storing format of cell and is_1904 flag in datetime struct for correcting conversation to any format.

It's a partial fix for #339 and this hack.

cc @lucatrv

src/datatype.rs Outdated
@@ -181,7 +180,7 @@ impl DataType {
let secs = days * 86400;
chrono::NaiveDateTime::from_timestamp_opt(secs, 0)
}
DataType::Float(f) | DataType::DateTime(f) => {
DataType::Float(f) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, it (Float/Int conversation) isn't necessary and can be removed in the future.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we can discard it. I wouldn't trust the excel file to have it properly encoded every time and I'd expect people to try getting a datetime anyway.
On the other maybe it is better to create an ExcelDateTime and call as_datetime?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other maybe it is better to create an ExcelDateTime and call as_datetime?

Thanks, I dit it.

Copy link
Owner

@tafia tafia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

src/datatype.rs Outdated Show resolved Hide resolved
src/datatype.rs Outdated
@@ -181,7 +180,7 @@ impl DataType {
let secs = days * 86400;
chrono::NaiveDateTime::from_timestamp_opt(secs, 0)
}
DataType::Float(f) | DataType::DateTime(f) => {
DataType::Float(f) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we can discard it. I wouldn't trust the excel file to have it properly encoded every time and I'd expect people to try getting a datetime anyway.
On the other maybe it is better to create an ExcelDateTime and call as_datetime?

@tafia
Copy link
Owner

tafia commented Jan 16, 2024

I'm sorry the the last PR added conflict to yours (DataType has been renamed to Data).

@dimastbk
Copy link
Contributor Author

@tafia fixed

@dimastbk
Copy link
Contributor Author

We can de duplicate some code with this - https://github.com/dimastbk/calamine/pull/1/files, but it seems less readable.

@tafia
Copy link
Owner

tafia commented Jan 16, 2024

I find both versions ok, up to you I'd say.
Thanks for the quick fix.

@dimastbk
Copy link
Contributor Author

Thanks, I prefer second variant.

@tafia
Copy link
Owner

tafia commented Jan 16, 2024

Thanks!

@tafia tafia merged commit 2620510 into tafia:master Jan 16, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants