-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from mhvk/leap-second-access
Leap second access following pattern from Astropy
- Loading branch information
Showing
8 changed files
with
374 additions
and
43 deletions.
There are no files selected for viewing
This file contains 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 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 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,93 @@ | ||
/* | ||
** Copyright (C) 2019, NumFOCUS Foundation. | ||
** | ||
** Licensed under a 3-clause BSD style license - see LICENSE | ||
** | ||
** This file is NOT derived from SOFA sources. | ||
** | ||
** The eraGetLeapSeconds and eraSetLeapSeconds functions are used as an | ||
** experimental interface for getting and setting the leap second table in | ||
** astropy 4.0. They will be supported as long as astropy 4.0 is supported | ||
** (until 2021), but not necessarily beyond. Comments and ideas about the | ||
** best way to keep the leap second tables up to date for all users of erfa | ||
** are welcome (https://github.com/liberfa/erfa). | ||
** | ||
** The eraDatini function is used internally in dat.c; it is strictly an | ||
** implementation detail and should not be used elsewhere. | ||
*/ | ||
#include "erfa.h" | ||
#include "erfaextra.h" | ||
|
||
static eraLEAPSECOND *changes; | ||
static int NDAT = -1; | ||
|
||
|
||
int eraGetLeapSeconds(eraLEAPSECOND **leapseconds) | ||
/* | ||
** Get the current leap second table. | ||
** | ||
** Returned: | ||
** leapseconds eraLEAPSECOND* Array of year, month, TAI minus UTC | ||
** | ||
** Returned (function value): | ||
** int NDAT Number of entries/status | ||
** >0 = number of entries | ||
** -1 = internal error | ||
*/ | ||
{ | ||
if (NDAT <= 0) { | ||
double delat; | ||
int stat = eraDat(2000, 1, 1, 0., &delat); | ||
if (stat != 0 || NDAT <= 0) { | ||
return -1; | ||
} | ||
} | ||
*leapseconds = changes; | ||
return NDAT; | ||
} | ||
|
||
void eraSetLeapSeconds(eraLEAPSECOND *leapseconds, int count) | ||
/* | ||
** Set the current leap second table. | ||
** | ||
** Given: | ||
** leapseconds eraLEAPSECOND* Array of year, month, TAI minus UTC | ||
** count int Number of entries. If <= 0, causes | ||
** a reset of the table to the built-in | ||
** version. | ||
** | ||
** Notes: | ||
** *No* sanity checks are performed. | ||
*/ | ||
{ | ||
changes = leapseconds; | ||
NDAT = count; | ||
} | ||
|
||
int eraDatini(const eraLEAPSECOND *builtin, int n_builtin, | ||
eraLEAPSECOND **leapseconds) | ||
/* | ||
** Get the leap second table, initializing it to the built-in version | ||
** if necessary. | ||
** | ||
** This function is for internal use in dat.c only and should | ||
** not be used elsewhere. | ||
** | ||
** Given: | ||
** builtin eraLEAPSECOND Array of year, month, TAI minus UTC | ||
** n_builtin int Number of entries of the table. | ||
** | ||
** Returned: | ||
** leapseconds eraLEAPSECOND* Current array, set to the builtin one | ||
** if not yet initialized. | ||
** | ||
** Returned (function value): | ||
** int NDAT Number of entries | ||
*/ | ||
{ | ||
if (NDAT <= 0) { | ||
eraSetLeapSeconds((eraLEAPSECOND *)builtin, n_builtin); | ||
} | ||
*leapseconds = changes; | ||
return NDAT; | ||
} |
This file contains 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,18 @@ | ||
/* | ||
** Copyright (C) 2019, NumFOCUS Foundation. | ||
** | ||
** Licensed under a 3-clause BSD style license - see LICENSE | ||
** | ||
** This file is NOT derived from SOFA sources. | ||
** | ||
*/ | ||
|
||
/* | ||
** Get the leap second table, initializing it to the built-in version | ||
** if necessary. | ||
** | ||
** This function is for internal use in dat.c only and should | ||
** not be used elsewhere. | ||
*/ | ||
int eraDatini(const eraLEAPSECOND *builtin, int n_builtin, | ||
eraLEAPSECOND **leapseconds); |
This file contains 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 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 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 |
---|---|---|
@@ -1,38 +1,51 @@ | ||
/* | ||
** Copyright (C) 2016-2017, NumFOCUS Foundation. | ||
** | ||
** Licensed under a 3-clause BSD style license - see LICENSE | ||
** Licensed under a 3-clause BSD style license - see LICENSE | ||
** | ||
** This file is NOT derived from SOFA sources | ||
*/ | ||
|
||
/* Define to the version of this package. */ | ||
#define PACKAGE_VERSION "1.6.0" | ||
|
||
/* Define to the major version of this package. */ | ||
#define PACKAGE_VERSION_MAJOR 1 | ||
|
||
/* Define to the micro version of this package. */ | ||
#define PACKAGE_VERSION_MICRO 0 | ||
|
||
/* Define to the minor version of this package. */ | ||
#define PACKAGE_VERSION_MINOR 6 | ||
|
||
/* Define to the version of SOFA */ | ||
#define SOFA_VERSION "20190722" | ||
|
||
#ifdef HAVE_CONFIG_H | ||
#include <config.h> | ||
#endif /* HAVE_CONFIG_H */ | ||
|
||
|
||
const char* eraVersion() { | ||
const char* eraVersion(void) { | ||
return PACKAGE_VERSION; | ||
} | ||
|
||
|
||
int eraVersionMajor() { | ||
int eraVersionMajor(void) { | ||
return PACKAGE_VERSION_MAJOR; | ||
} | ||
|
||
|
||
int eraVersionMinor() { | ||
int eraVersionMinor(void) { | ||
return PACKAGE_VERSION_MINOR; | ||
} | ||
|
||
|
||
int eraVersionMicro() { | ||
int eraVersionMicro(void) { | ||
return PACKAGE_VERSION_MICRO; | ||
} | ||
|
||
|
||
const char* eraSofaVersion() { | ||
const char* eraSofaVersion(void) { | ||
return SOFA_VERSION; | ||
} | ||
|
Oops, something went wrong.