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

time handling #179

Merged
merged 7 commits into from
Dec 13, 2019
Merged

time handling #179

merged 7 commits into from
Dec 13, 2019

Conversation

vcloarec
Copy link
Collaborator

@vcloarec vcloarec commented Dec 9, 2019

For discussion

Copy link
Contributor

@PeterPetrik PeterPetrik left a comment

Choose a reason for hiding this comment

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

Generally I am happy with the approach of creation separate classes Duration/DateTime for handling time in the nice matter.

We need a very good test suite for just these 2 classes to be sure it works as we expect (so we need to unittest directly these classes)

What I would suggest is to use internally some C++/C time/datetime library and have Duration/DateTime just as wrapper around this library (if we can find such library). The convertion of these times are a bit tricky, especially with timezones (if we want to support that). look on https://github.com/HowardHinnant/date or similar to see if it is any help

@wonder-sk mentioned there is some article from google devs why to not try to create your own time library.

tests/test_tuflowfv.cpp Outdated Show resolved Hide resolved
tests/mdal_testutils.cpp Show resolved Hide resolved
mdal/mdal_utils.hpp Outdated Show resolved Hide resolved
mdal/mdal_data_model.hpp Outdated Show resolved Hide resolved
mdal/mdal_data_model.hpp Outdated Show resolved Hide resolved
mdal/mdal_data_model.cpp Outdated Show resolved Hide resolved
mdal/mdal_data_model.cpp Outdated Show resolved Hide resolved
mdal/mdal_data_model.cpp Outdated Show resolved Hide resolved
mdal/frmts/mdal_binary_dat.cpp Outdated Show resolved Hide resolved
mdal/mdal_data_model.cpp Outdated Show resolved Hide resolved
@PeterPetrik PeterPetrik added this to the MDAL 0.5.0 milestone Dec 9, 2019
@PeterPetrik PeterPetrik added the enhancement New feature or request label Dec 9, 2019
@vcloarec
Copy link
Collaborator Author

vcloarec commented Dec 9, 2019

@wonder-sk I will be happy if you have linked toward this article

@@ -161,7 +161,78 @@ static void populate_vals( bool is_vector, double *vals, size_t i,
}
}

void MDAL::DriverCF::addDatasetGroups( MDAL::Mesh *mesh, const std::vector<double> &times, const MDAL::cfdataset_info_map &dsinfo_map )
static MDAL::DateTime parseReferenceTime( std::string timeInformation, std::string calendar )
Copy link
Contributor

Choose a reason for hiding this comment

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

const std::string&

@wonder-sk
Copy link
Member

@vcloarec unfortunately I can't find the original article... but this one also give quite a good list about some false assumptions programmers make about time: https://infiniteundo.com/post/25326999628/falsehoods-programmers-believe-about-time

tests/test_sww.cpp Outdated Show resolved Hide resolved
@vcloarec vcloarec force-pushed the master branch 5 times, most recently from 1fed060 to c948bda Compare December 12, 2019 01:11
@vcloarec vcloarec changed the title [WIP] time handling time handling Dec 12, 2019
Copy link
Contributor

@PeterPetrik PeterPetrik left a comment

Choose a reason for hiding this comment

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

very good work

one think I would ask you to change. We talked with Martin and we would like to change Duration to RelativeTimestamp. Duration associates with some internal, but the information store in that case is not internal, it is timestamp...

mdal/frmts/mdal_flo2d.cpp Show resolved Hide resolved
mdal/frmts/mdal_gdal.cpp Outdated Show resolved Hide resolved
mdal/frmts/mdal_gdal.cpp Outdated Show resolved Hide resolved
mdal/frmts/mdal_gdal.hpp Outdated Show resolved Hide resolved
double valid_time = parseMetadataTime( iter->second );
*time = ( valid_time - mRefTime ) / 3600.0; // input times are always in seconds UTC, we need them back in hours
DateTime valid_time = DateTime( parseMetadataTime( iter->second ), DateTime::Unix );
*time = ( valid_time - mRefTime );
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't this missing division by /3600?

would be good to have test in test suite to catch these regressions

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

tested indirectly here :

EXPECT_TRUE( compareDurationInHours( 12, time ) );

tests/test_mdal_date_time.cpp Outdated Show resolved Hide resolved
tests/test_mdal_date_time.cpp Outdated Show resolved Hide resolved
tests/test_mdal_date_time.cpp Outdated Show resolved Hide resolved
tests/test_mdal_date_time.cpp Outdated Show resolved Hide resolved
tests/test_xdmf.cpp Outdated Show resolved Hide resolved
@vcloarec vcloarec force-pushed the master branch 2 times, most recently from d58728d to 33e8ecb Compare December 13, 2019 00:24
few modifications and corrections
@PeterPetrik PeterPetrik merged commit 9f80268 into lutraconsulting:master Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants