-
Notifications
You must be signed in to change notification settings - Fork 4
Time extension #91
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
Merged
Merged
Time extension #91
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8ea5a8a
feat: add asdf/core/time-1.4.0 extension
embray 9c8d138
test: use per-process-group run directory for temp files
embray a7e03d3
test: add tests for time extension and fix core extensions test
embray d3086c4
style: clean up `clang tidy` warnings in tests/util.c; splitting up
embray a1376de
build: fix distcheck
embray File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| /** Data type and extension for the stsci.edu/schemas/asdf/time/time schema */ | ||
| #ifndef ASDF_CORE_TIME_H | ||
| #define ASDF_CORE_TIME_H | ||
|
|
||
| #include <asdf/extension.h> | ||
| #include <sys/time.h> | ||
|
|
||
|
|
||
| ASDF_BEGIN_DECLS | ||
|
|
||
| #define ASDF_CORE_TIME_TAG "tag:stsci.edu:asdf/time/time-1.4.0" | ||
| #define ASDF_TIME_TIMESTR_MAXLEN 255 | ||
|
|
||
| typedef enum { | ||
| ASDF_TIME_FORMAT_ISO_TIME = 0, | ||
| ASDF_TIME_FORMAT_YDAY, | ||
| ASDF_TIME_FORMAT_BYEAR, | ||
| ASDF_TIME_FORMAT_JYEAR, | ||
| ASDF_TIME_FORMAT_DECIMALYEAR, | ||
| ASDF_TIME_FORMAT_JD, | ||
| ASDF_TIME_FORMAT_MJD, | ||
| ASDF_TIME_FORMAT_GPS, | ||
| ASDF_TIME_FORMAT_UNIX, | ||
| ASDF_TIME_FORMAT_UTIME, | ||
| ASDF_TIME_FORMAT_TAI_SECONDS, | ||
| ASDF_TIME_FORMAT_CXCSEC, | ||
| ASDF_TIME_FORMAT_GALEXSEC, | ||
| ASDF_TIME_FORMAT_UNIX_TAI, | ||
| ASDF_TIME_FORMAT_RESERVED1, | ||
| /* "other" format(s) below */ | ||
| ASDF_TIME_FORMAT_BYEAR_STR, | ||
| ASDF_TIME_FORMAT_DATETIME, | ||
| ASDF_TIME_FORMAT_FITS, | ||
| ASDF_TIME_FORMAT_ISOT, | ||
| ASDF_TIME_FORMAT_JYEAR_STR, | ||
| ASDF_TIME_FORMAT_PLOT_DATE, | ||
| ASDF_TIME_FORMAT_YMDHMS, | ||
| ASDF_TIME_FORMAT_datetime64, | ||
| } asdf_time_base_format_t; | ||
|
|
||
|
|
||
| typedef enum { | ||
| ASDF_TIME_SCALE_UTC = 0, | ||
| ASDF_TIME_SCALE_TAI, | ||
| ASDF_TIME_SCALE_TCB, | ||
| ASDF_TIME_SCALE_TCG, | ||
| ASDF_TIME_SCALE_TDB, | ||
| ASDF_TIME_SCALE_TT, | ||
| ASDF_TIME_SCALE_UT1, | ||
| } asdf_time_scale_t; | ||
|
|
||
| typedef struct { | ||
| double longitude; | ||
| double latitude; | ||
| double height; | ||
| } asdf_time_location_t; | ||
|
|
||
| typedef struct { | ||
| bool is_base_format; | ||
| asdf_time_base_format_t type; | ||
| } asdf_time_format_t; | ||
|
|
||
| struct asdf_time_info_t { | ||
| struct timespec ts; | ||
| struct tm tm; | ||
| }; | ||
|
|
||
| typedef struct { | ||
| char *value; | ||
| struct asdf_time_info_t info; | ||
| asdf_time_format_t format; | ||
| asdf_time_scale_t scale; | ||
| asdf_time_location_t location; | ||
| } asdf_time_t; | ||
|
|
||
| ASDF_DECLARE_EXTENSION(time, asdf_time_t); | ||
|
|
||
| ASDF_LOCAL int asdf_time_parse_std( | ||
| const char *s, const asdf_time_format_t *format, struct asdf_time_info_t *out); | ||
| ASDF_LOCAL int asdf_time_parse_byear(const char *s, struct asdf_time_info_t *out); | ||
| ASDF_LOCAL int asdf_time_parse_yday(const char *s, struct asdf_time_info_t *out); | ||
|
|
||
|
|
||
| ASDF_END_DECLS | ||
|
|
||
| #endif /* ASDF_CORE_TIME_H */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, but then don't use the
_tsuffix for anything that isn't typedef'd; then it's hard to remember it needsstruct:)