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

[Bug]: io.timestamp2datetime does not work for some edgecase dates #585

Closed
2 tasks done
ehennestad opened this issue Sep 3, 2024 · 0 comments · Fixed by #586
Closed
2 tasks done

[Bug]: io.timestamp2datetime does not work for some edgecase dates #585

ehennestad opened this issue Sep 3, 2024 · 0 comments · Fixed by #586

Comments

@ehennestad
Copy link
Collaborator

ehennestad commented Sep 3, 2024

What happened?

For some dates that come at the end of a month, the io.timestamp2datetime function returns the wrong date in the output.

Steps to Reproduce

NWBDefaultStringFormat = "uuuu-MM-dd'T'HH:mm:ss.SSSSSSZZZZZ";

testDate = datetime(2024, 8, 31, 'TimeZone', 'local'); % Start date: January 1st
testDate.Format = NWBDefaultStringFormat;
testDateAsString = string(testDate);

io.timestamp2datetime(testDateAsString)

ans = 

  datetime

   01-Aug-2024

Error Message

No response

Operating System

macOS

Matlab Version

MATLAB Version: 23.2.0.2365128 (R2023b)

Code of Conduct

ehennestad added a commit that referenced this issue Sep 3, 2024
Some dates are assigned wrongly when Day, Month and Year are set individually, as the datetime object internally/silently adjusts month if day is not valid
bendichter pushed a commit that referenced this issue Sep 10, 2024
* Fix bug in io.timestamp2datetime (Issue #585)

Some dates are assigned wrongly when Day, Month and Year are set individually, as the datetime object internally/silently adjusts month if day is not valid

* Update timestamp2datetime.m

Fix: Should not preallocate datetimeArray as it is not known beforehand whether the timestamp has a timezone or not (datetime.empty contrains to datetime w/o timezone)

* Create testTimestampToDatetime.m

Add unit test for io.timestamp2datetime function
bendichter added a commit that referenced this issue Sep 12, 2024
* Improve coverage for nwbRead/nwbExport

* Remove tutorialTest (function-based)

* Create TutorialTest (class-based unit test)

* Add test classes (issue #583 )

* Update description for PynwbTutorialTest

* Add specific tests for io.timestamp2datetime

* Update unit tests

* Create getTutorialNwbFilePath.m

Add function to create a filepath for saving tutorial nwb files in a fixed folder

* Fix: Add starting_time when creating TimeSeries objects (#584)

Also, use misc.getTutorialNwbFilePath to create a filepath for saving tutorial nwb file

* Update several tutorials: Specify timezone or NWBFile's session_start_time property

* Fix bug in io.timestamp2datetime (Issue #585)

Some dates are assigned wrongly when Day, Month and Year are set individually, as the datetime object internally/silently adjusts month if day is not valid

* Update timestamp2datetime.m

Fix: Should not preallocate datetimeArray as it is not known beforehand whether the timestamp has a timezone or not (datetime.empty contrains to datetime w/o timezone)

* Update GenerationTest.m

Ensure test can be run from any current working directory, not just the matnwb repo folder

* Update getMatnwbDir.m

Simplyfy function by using mfilename instead of dbstack

* Delete file which was introduced with issue #585

* Change nwbtest: Add selector options as input; Add cleanup routine

* Add test for constructing Anon with name, value input

* Add specific testing of types.untyped.Set

When writing test, also discovered a but in types.untyped.Set which is fixed

* Remove function call used for debugging

---------

Co-authored-by: Ben Dichter <[email protected]>
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 a pull request may close this issue.

1 participant