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

Change datetime fields to date fields in BagInfoMetadata model. #634

Conversation

McDaPick
Copy link
Contributor

This PR is for Issue #506

After updating the date_start and date_end fields in the BagInfoMetadata model from

date_start = models.DateTimeField()
date_end = models.DateTimeField()

to

date_start = models.DateField()
date_end = models.DateField()

and running a migration, the date was being saved as one day earlier than what was in the bag-info file.

Transfer's Bag Info:

External Identifier: records-2017-12-11T20:09:48.238148
BagIt-Profile-Identifier: http://localhost:8000/api/bagit_profiles/2/
Bagging-Date: 2017-12-11T20:09:48.238148
Date-End: 2005-06-22
Date-Start: 2003-05-14

The Transfer's data through the Django shell after being imported:

>>> from bag_transfer.models import BagInfoMetadata
>>> x = BagInfoMetadata.objects.get(external_identifier="records-2017-12-11T20:09:48.238148")
>>> print(x.date_end)
2005-06-21
>>> print(x.date_start)
2003-05-13

Inside of the Transfer's detail view:

image

After reading @helrond comment about timezone/daylight, I started to take a look around and saw that config.py has the time zone set as America/New_York on line 15.

DJANGO_TIME_ZONE = "America/New_York"  # TZ database name for local timezone (string)

Updating this value to UTC allowed for the date_field to save correctly.

DJANGO_TIME_ZONE = "UTC"  # TZ database name for local timezone (string)

Transfer's Bag Info:

External Identifier: records-2017-12-11T20:09:48.238148
BagIt-Profile-Identifier: http://localhost:8000/api/bagit_profiles/2/
Bagging-Date: 2017-12-11T20:09:48.238148
Date-End: 2005-06-22
Date-Start: 2003-05-14

The Transfer's data through the Django shell after DJANGO_TIME_ZONE was updated:

>>> from bag_transfer.models import BagInfoMetadata
>>> x = BagInfoMetadata.objects.get(external_identifier="records-2017-12-11T20:09:48.238148")
>>> print(x.date_end)
2005-06-22
>>> print(x.date_start)
2003-05-14

Inside of the Transfer's detail view:

image

Side Note:

This update to the DJANGO_TIME_ZONE also seems to fix the bagging_date time being fives hours off of its value in bag-data.

@helrond helrond changed the base branch from base to issue-506 November 2, 2023 01:37
@helrond helrond merged commit 83ffeb1 into RockefellerArchiveCenter:issue-506 Nov 2, 2023
1 check failed
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.

None yet

2 participants