diff --git a/docs/reference/swe-glib/swe-glib-sections.txt b/docs/reference/swe-glib/swe-glib-sections.txt index f3b5a8e..cab9b5d 100644 --- a/docs/reference/swe-glib/swe-glib-sections.txt +++ b/docs/reference/swe-glib/swe-glib-sections.txt @@ -268,6 +268,7 @@ gswe_timestamp_set_julian_day_et gswe_timestamp_get_julian_day_et gswe_timestamp_set_julian_day_ut gswe_timestamp_get_julian_day_ut +gswe_timestamp_get_sidereal_time GSWE_IS_TIMESTAMP GSWE_IS_TIMESTAMP_CLASS diff --git a/src/gswe-timestamp.c b/src/gswe-timestamp.c index 6edcd2e..a2292b1 100644 --- a/src/gswe-timestamp.c +++ b/src/gswe-timestamp.c @@ -985,6 +985,38 @@ gswe_timestamp_get_julian_day_ut(GsweTimestamp *timestamp, GError **err) return timestamp->priv->julian_day_ut; } +/** + * gswe_timestamp_get_sidereal_time: + * @timestamp: a GsweTimestamp + * @err: a #GError + * + * Gets the sidereal time on the Greenwich Meridian. + * + * Returns: the sidereal time in hours. To get the degrees, multiply this value + * by 15. + * + * Since: 2.1 + */ +gdouble +gswe_timestamp_get_sidereal_time(GsweTimestamp *timestamp, GError **err) +{ + GError *local_err = NULL; + + gswe_timestamp_calculate_julian(timestamp, &local_err); + + if (local_err) { + if (err) { + *err = local_err; + } else { + g_error_free(local_err); + } + + return 0.0; + } + + return swe_sidtime(timestamp->priv->julian_day_ut); +} + /** * gswe_timestamp_new: * diff --git a/src/gswe-timestamp.h b/src/gswe-timestamp.h index 513950c..4f751a4 100644 --- a/src/gswe-timestamp.h +++ b/src/gswe-timestamp.h @@ -119,6 +119,7 @@ void gswe_timestamp_set_julian_day_et(GsweTimestamp *timestamp, gdouble julian_d gdouble gswe_timestamp_get_julian_day_et(GsweTimestamp *timestamp, GError **err); void gswe_timestamp_set_julian_day_ut(GsweTimestamp *timestamp, gdouble julian_day, GError **err); gdouble gswe_timestamp_get_julian_day_ut(GsweTimestamp *timestamp, GError **err); +gdouble gswe_timestamp_get_sidereal_time(GsweTimestamp *timestamp, GError **err); #endif /* __SWE_GLIB_GSWE_TIMESTAMP_H__ */