Make TimestampValidity public with name GsweTimestampValidityFlags

This commit is contained in:
Gergely Polonkai 2014-11-17 10:20:10 +01:00
parent b4612e1e89
commit 6187d45177
3 changed files with 39 additions and 30 deletions

View File

@ -249,6 +249,7 @@ gswe_house_data_get_type
<TITLE>GsweTimestamp</TITLE> <TITLE>GsweTimestamp</TITLE>
GsweTimestamp GsweTimestamp
GsweTimestampClass GsweTimestampClass
GsweTimestampValidityFlags
gswe_timestamp_new gswe_timestamp_new
gswe_timestamp_new_from_julian_day gswe_timestamp_new_from_julian_day
gswe_timestamp_new_from_gregorian_full gswe_timestamp_new_from_gregorian_full

View File

@ -40,14 +40,9 @@
GsweTimestampPrivate \ GsweTimestampPrivate \
)) ))
typedef enum {
VALID_GREGORIAN = 1 << 0,
VALID_JULIAN_DAY = 1 << 1
} TimestampValidity;
struct _GsweTimestampPrivate { struct _GsweTimestampPrivate {
gboolean instant_recalc; gboolean instant_recalc;
TimestampValidity valid_dates; GsweTimestampValidityFlags valid_dates;
gint gregorian_year; gint gregorian_year;
gint gregorian_month; gint gregorian_month;
@ -518,8 +513,8 @@ gswe_timestamp_get_property(
case PROP_GREGORIAN_VALID: case PROP_GREGORIAN_VALID:
g_value_set_boolean( g_value_set_boolean(
value, value,
((timestamp->priv->valid_dates & VALID_GREGORIAN) ((timestamp->priv->valid_dates & GSWE_VALID_GREGORIAN)
== VALID_GREGORIAN) == GSWE_VALID_GREGORIAN)
); );
break; break;
@ -584,8 +579,8 @@ gswe_timestamp_get_property(
case PROP_JULIAN_DAY_VALID: case PROP_JULIAN_DAY_VALID:
g_value_set_boolean( g_value_set_boolean(
value, value,
((timestamp->priv->valid_dates & VALID_JULIAN_DAY) ((timestamp->priv->valid_dates & GSWE_VALID_JULIAN_DAY)
== VALID_JULIAN_DAY) == GSWE_VALID_JULIAN_DAY)
); );
break; break;
@ -600,11 +595,11 @@ gswe_timestamp_get_property(
static void static void
gswe_timestamp_calculate_all(GsweTimestamp *timestamp, GError **err) gswe_timestamp_calculate_all(GsweTimestamp *timestamp, GError **err)
{ {
if ((timestamp->priv->valid_dates & VALID_JULIAN_DAY) != VALID_JULIAN_DAY) { if ((timestamp->priv->valid_dates & GSWE_VALID_JULIAN_DAY) != GSWE_VALID_JULIAN_DAY) {
gswe_timestamp_calculate_julian(timestamp, err); gswe_timestamp_calculate_julian(timestamp, err);
} }
if ((timestamp->priv->valid_dates & VALID_GREGORIAN) != VALID_GREGORIAN) { if ((timestamp->priv->valid_dates & GSWE_VALID_GREGORIAN) != GSWE_VALID_GREGORIAN) {
gswe_timestamp_calculate_gregorian(timestamp, err); gswe_timestamp_calculate_gregorian(timestamp, err);
} }
} }
@ -620,7 +615,7 @@ gswe_timestamp_calculate_gregorian(GsweTimestamp *timestamp, GError **err)
gdouble utc_second, gdouble utc_second,
local_second; local_second;
if ((timestamp->priv->valid_dates & VALID_GREGORIAN) == VALID_GREGORIAN) { if ((timestamp->priv->valid_dates & GSWE_VALID_GREGORIAN) == GSWE_VALID_GREGORIAN) {
return; return;
} }
@ -857,7 +852,7 @@ gswe_timestamp_set_gregorian_full(
gswe_timestamp_props[PROP_JULIAN_DAY_VALID] gswe_timestamp_props[PROP_JULIAN_DAY_VALID]
); );
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = GSWE_VALID_GREGORIAN;
if (timestamp->priv->instant_recalc == TRUE) { if (timestamp->priv->instant_recalc == TRUE) {
gswe_timestamp_calculate_all(timestamp, err); gswe_timestamp_calculate_all(timestamp, err);
@ -889,7 +884,7 @@ gswe_timestamp_set_gregorian_year(
} }
timestamp->priv->gregorian_year = gregorian_year; timestamp->priv->gregorian_year = gregorian_year;
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = GSWE_VALID_GREGORIAN;
g_object_notify_by_pspec( g_object_notify_by_pspec(
G_OBJECT(timestamp), G_OBJECT(timestamp),
@ -950,7 +945,7 @@ gswe_timestamp_set_gregorian_month(
} }
timestamp->priv->gregorian_month = gregorian_month; timestamp->priv->gregorian_month = gregorian_month;
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = GSWE_VALID_GREGORIAN;
g_object_notify_by_pspec( g_object_notify_by_pspec(
G_OBJECT(timestamp), G_OBJECT(timestamp),
gswe_timestamp_props[PROP_GREGORIAN_VALID] gswe_timestamp_props[PROP_GREGORIAN_VALID]
@ -1010,7 +1005,7 @@ gswe_timestamp_set_gregorian_day(
} }
timestamp->priv->gregorian_day = gregorian_day; timestamp->priv->gregorian_day = gregorian_day;
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = GSWE_VALID_GREGORIAN;
g_object_notify_by_pspec( g_object_notify_by_pspec(
G_OBJECT(timestamp), G_OBJECT(timestamp),
gswe_timestamp_props[PROP_GREGORIAN_VALID] gswe_timestamp_props[PROP_GREGORIAN_VALID]
@ -1070,7 +1065,7 @@ gswe_timestamp_set_gregorian_hour(
} }
timestamp->priv->gregorian_hour = gregorian_hour; timestamp->priv->gregorian_hour = gregorian_hour;
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = GSWE_VALID_GREGORIAN;
g_object_notify_by_pspec( g_object_notify_by_pspec(
G_OBJECT(timestamp), G_OBJECT(timestamp),
gswe_timestamp_props[PROP_GREGORIAN_VALID] gswe_timestamp_props[PROP_GREGORIAN_VALID]
@ -1130,7 +1125,7 @@ gswe_timestamp_set_gregorian_minute(
} }
timestamp->priv->gregorian_minute = gregorian_minute; timestamp->priv->gregorian_minute = gregorian_minute;
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = GSWE_VALID_GREGORIAN;
g_object_notify_by_pspec( g_object_notify_by_pspec(
G_OBJECT(timestamp), G_OBJECT(timestamp),
gswe_timestamp_props[PROP_GREGORIAN_VALID] gswe_timestamp_props[PROP_GREGORIAN_VALID]
@ -1190,7 +1185,7 @@ gswe_timestamp_set_gregorian_second(
} }
timestamp->priv->gregorian_second = gregorian_second; timestamp->priv->gregorian_second = gregorian_second;
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = GSWE_VALID_GREGORIAN;
g_object_notify_by_pspec( g_object_notify_by_pspec(
G_OBJECT(timestamp), G_OBJECT(timestamp),
gswe_timestamp_props[PROP_GREGORIAN_VALID] gswe_timestamp_props[PROP_GREGORIAN_VALID]
@ -1250,7 +1245,7 @@ gswe_timestamp_set_gregorian_microsecond(
} }
timestamp->priv->gregorian_microsecond = gregorian_microsecond; timestamp->priv->gregorian_microsecond = gregorian_microsecond;
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = GSWE_VALID_GREGORIAN;
g_object_notify_by_pspec( g_object_notify_by_pspec(
G_OBJECT(timestamp), G_OBJECT(timestamp),
gswe_timestamp_props[PROP_GREGORIAN_VALID] gswe_timestamp_props[PROP_GREGORIAN_VALID]
@ -1311,7 +1306,7 @@ gswe_timestamp_set_gregorian_timezone(
gswe_timestamp_calculate_julian(timestamp, NULL); gswe_timestamp_calculate_julian(timestamp, NULL);
timestamp->priv->gregorian_timezone_offset = gregorian_timezone_offset; timestamp->priv->gregorian_timezone_offset = gregorian_timezone_offset;
timestamp->priv->valid_dates &= ~VALID_GREGORIAN; timestamp->priv->valid_dates &= ~GSWE_VALID_GREGORIAN;
g_object_notify_by_pspec( g_object_notify_by_pspec(
G_OBJECT(timestamp), G_OBJECT(timestamp),
@ -1348,7 +1343,7 @@ gswe_timestamp_calculate_julian(GsweTimestamp *timestamp, GError **err)
dret[2]; dret[2];
gchar serr[AS_MAXCH]; gchar serr[AS_MAXCH];
if ((timestamp->priv->valid_dates & VALID_JULIAN_DAY) == VALID_JULIAN_DAY) { if ((timestamp->priv->valid_dates & GSWE_VALID_JULIAN_DAY) == GSWE_VALID_JULIAN_DAY) {
return; return;
} }
@ -1389,7 +1384,7 @@ gswe_timestamp_calculate_julian(GsweTimestamp *timestamp, GError **err)
} else { } else {
timestamp->priv->julian_day = dret[0]; timestamp->priv->julian_day = dret[0];
timestamp->priv->julian_day_ut = dret[1]; timestamp->priv->julian_day_ut = dret[1];
timestamp->priv->valid_dates |= VALID_JULIAN_DAY; timestamp->priv->valid_dates |= GSWE_VALID_JULIAN_DAY;
} }
} }
@ -1443,7 +1438,7 @@ gswe_timestamp_set_julian_day_et(
GError *err_local = NULL; GError *err_local = NULL;
timestamp->priv->julian_day = julian_day; timestamp->priv->julian_day = julian_day;
timestamp->priv->valid_dates = VALID_JULIAN_DAY; timestamp->priv->valid_dates = GSWE_VALID_JULIAN_DAY;
g_object_notify_by_pspec( g_object_notify_by_pspec(
G_OBJECT(timestamp), G_OBJECT(timestamp),
gswe_timestamp_props[PROP_GREGORIAN_VALID] gswe_timestamp_props[PROP_GREGORIAN_VALID]
@ -1466,7 +1461,7 @@ gswe_timestamp_set_julian_day_et(
return; return;
} }
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = GSWE_VALID_GREGORIAN;
g_object_notify_by_pspec( g_object_notify_by_pspec(
G_OBJECT(timestamp), G_OBJECT(timestamp),
gswe_timestamp_props[PROP_GREGORIAN_VALID] gswe_timestamp_props[PROP_GREGORIAN_VALID]
@ -1533,7 +1528,7 @@ gswe_timestamp_set_julian_day_ut(
GError *err_local = NULL; GError *err_local = NULL;
timestamp->priv->julian_day_ut = julian_day; timestamp->priv->julian_day_ut = julian_day;
timestamp->priv->valid_dates = VALID_JULIAN_DAY; timestamp->priv->valid_dates = GSWE_VALID_JULIAN_DAY;
g_object_notify_by_pspec( g_object_notify_by_pspec(
G_OBJECT(timestamp), G_OBJECT(timestamp),
gswe_timestamp_props[PROP_GREGORIAN_VALID] gswe_timestamp_props[PROP_GREGORIAN_VALID]
@ -1556,7 +1551,7 @@ gswe_timestamp_set_julian_day_ut(
return; return;
} }
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = GSWE_VALID_GREGORIAN;
g_object_notify_by_pspec( g_object_notify_by_pspec(
G_OBJECT(timestamp), G_OBJECT(timestamp),
gswe_timestamp_props[PROP_GREGORIAN_VALID] gswe_timestamp_props[PROP_GREGORIAN_VALID]
@ -1686,7 +1681,7 @@ gswe_timestamp_new_from_gregorian_full(
"gregorian-timezone-offset", time_zone_offset, "gregorian-timezone-offset", time_zone_offset,
NULL)); NULL));
timestamp->priv->valid_dates = VALID_GREGORIAN; timestamp->priv->valid_dates = GSWE_VALID_GREGORIAN;
return timestamp; return timestamp;
} }

View File

@ -307,6 +307,20 @@ typedef enum {
GSWE_MOON_PHASE_DARK GSWE_MOON_PHASE_DARK
} GsweMoonPhase; } GsweMoonPhase;
/**
* GsweTimestampValidityFlags:
* @GSWE_VALID_NONE: No valid timestamp
* @GSWE_VALID_GREGORIAN: Gregorian timestamp is valid
* @GSWE_VALID_JULIAN_DAY: Julian Day is valid
*
* Flags to show the valid values in a #GsweTimestamp
*/
typedef enum {
GSWE_VALID_NONE = 0,
GSWE_VALID_GREGORIAN = (1 << 0),
GSWE_VALID_JULIAN_DAY = (1 << 1)
} GsweTimestampValidityFlags;
/** /**
* GsweCoordinates: * GsweCoordinates:
* @longitude: longitude part of the coordinates * @longitude: longitude part of the coordinates
@ -325,4 +339,3 @@ GType gswe_coordinates_get_type(void);
#define GSWE_TYPE_COORDINATES (gswe_coordinates_get_type()) #define GSWE_TYPE_COORDINATES (gswe_coordinates_get_type())
#endif /* __SWE_GLIB_GSWE_TYPES_H__ */ #endif /* __SWE_GLIB_GSWE_TYPES_H__ */