Skip to content

fix: more fixes to time parsing#205

Merged
embray merged 1 commit into
asdf-format:mainfrom
embray:time-fixes-2
Jun 24, 2026
Merged

fix: more fixes to time parsing#205
embray merged 1 commit into
asdf-format:mainfrom
embray:time-fixes-2

Conversation

@embray

@embray embray commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

While working on gh-201 I wanted to use setting a time as a simple example but exercising the time extension more revealed further problems:

  • parsing doesn't work for jyear format times -- this is now added, as well as for the decimalyear format; leaving more formats to support for a follow-up issue

  • corrected not-quite-right handling of time values given as numerical scalars; rather than parsing their numerical values out of YAML and then re-formatting them, just take the YAML scalar verbatim, as the individual format parsers expect

  • fixed deserialization of the optional 'scale' property, which previously always defaulted to 'utc'. This was a certainly intended as a TODO but forgot to note it

While working on asdf-formatgh-201 I wanted to use setting a time as a simple
example but exercising the time extension more revealed further
problems:

- parsing doesn't work for jyear format times -- this is now added,
  as well as for the decimalyear format; leaving more formats to
  support for a follow-up issue

- corrected not-quite-right handling of time values given as numerical
  scalars; rather than parsing their numerical values out of YAML and
  then re-formatting them, just take the YAML scalar verbatim, as the
  individual format parsers expect

- fixed deserialization of the optional 'scale' property, which
  previously always defaulted to 'utc'.  This was a certainly intended
  as a TODO but forgot to note it
Comment thread src/core/time.c
* determined. The return type is a signed ``int`` (not the enum) because
* `asdf_time_format_t` may be an unsigned type, in which case a -1 enum value
* would compare as a large positive number.
*/

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Also fixed this -- a mistake a make frequently actually. It's not portable to treat an enum value as a signed int.

@embray embray merged commit fde52cc into asdf-format:main Jun 24, 2026
12 checks passed
@embray embray deleted the time-fixes-2 branch June 24, 2026 11:42
@embray

embray commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator Author

Ah shoot, I jumped the gun a little on this, because this still doesn't actually fix the case I was trying to fix for #201.

embray added a commit that referenced this pull request Jun 24, 2026
For values in decimal formats the time format is ambiguous and should
not be guessed.  Likewise, according the the actual schema, the string
formats are only valid in the schema if they are guessable, basically
(i.e. 'J2000.0', not just '2000.0', even if `format: jyear` is
specified.

Follow-up to #205 which intended to fix this as well.
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.

1 participant