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

Incorrect logic for determining if a unit is a date unit #523

Open
pelson opened this issue Nov 16, 2024 · 0 comments
Open

Incorrect logic for determining if a unit is a date unit #523

pelson opened this issue Nov 16, 2024 · 0 comments
Labels
New: Issue Highlight a new community raised "generic" issue Type: Bug

Comments

@pelson
Copy link
Member

pelson commented Nov 16, 2024

I was looking to implement the separation of date from unit in pyudunits2 and took a look over the existing cf-units logic to determine if something is a time reference:

return self.calendar is not None

Then, I wondered how this calendar came to being...

if _OP_SINCE in unit.lower():

Which is surprising, because the existence of shift isn't a guarantee that it is a date. Take temperatures for example:

>>> degC = cf_units.Unit('kelvin since 273.15')
>>> degC.is_time_reference()
True

udunits2 does not delineate the type of shift that it does based on how shift is spelt. It is quite common to see degC defined as kelvin @ 273.15, which would return False for is_time_reference... but then so would:

>>> seconds_since_2000 = cf_units.Unit('seconds @ 2000-01-01T00:00 UTC')
>>> seconds_since_2000.is_time_reference()
False

I'm not clear is there is an actual way to fix this with udunits2. Date handling is messy, and highly context dependent as I am learning in pelson/pyudunits2#4

@pelson pelson added Type: Bug New: Issue Highlight a new community raised "generic" issue labels Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New: Issue Highlight a new community raised "generic" issue Type: Bug
Projects
None yet
Development

No branches or pull requests

1 participant