Date and Time Functions

Name

Date and Time Functions —

Synopsis


#include <glib.h>


struct      GTimeVal;
void        g_get_current_time              (GTimeVal *result);

typedef     GTime;
struct      GDate;
enum        GDateDMY;
typedef     GDateDay;
enum        GDateMonth;
enum        GDateWeekday;
typedef     GDateYear;
#define     G_DATE_BAD_DAY
#define     G_DATE_BAD_JULIAN
#define     G_DATE_BAD_YEAR
void        g_date_add_days                 (GDate *date,
                                             guint n_days);
void        g_date_add_months               (GDate *date,
                                             guint n_months);
void        g_date_add_years                (GDate *date,
                                             guint n_years);
void        g_date_clear                    (GDate *date,
                                             guint n_dates);
gint        g_date_compare                  (GDate *lhs,
                                             GDate *rhs);
GDateDay    g_date_day                      (GDate *date);
guint       g_date_day_of_year              (GDate *date);
guint8      g_date_days_in_month            (GDateMonth month,
                                             GDateYear year);
void        g_date_free                     (GDate *date);
gboolean    g_date_is_first_of_month        (GDate *date);
gboolean    g_date_is_last_of_month         (GDate *date);
gboolean    g_date_is_leap_year             (GDateYear year);
guint32     g_date_julian                   (GDate *date);
guint       g_date_monday_week_of_year      (GDate *date);
guint8      g_date_monday_weeks_in_year     (GDateYear year);
GDateMonth  g_date_month                    (GDate *date);
GDate*      g_date_new                      (void);
GDate*      g_date_new_dmy                  (GDateDay day,
                                             GDateMonth month,
                                             GDateYear year);
GDate*      g_date_new_julian               (guint32 julian_day);
void        g_date_set_day                  (GDate *date,
                                             GDateDay day);
void        g_date_set_dmy                  (GDate *date,
                                             GDateDay day,
                                             GDateMonth month,
                                             GDateYear y);
void        g_date_set_julian               (GDate *date,
                                             guint32 julian_date);
void        g_date_set_month                (GDate *date,
                                             GDateMonth month);
void        g_date_set_parse                (GDate *date,
                                             const gchar *str);
void        g_date_set_time                 (GDate *date,
                                             GTime time);
void        g_date_set_year                 (GDate *date,
                                             GDateYear year);
gsize       g_date_strftime                 (gchar *s,
                                             gsize slen,
                                             const gchar *format,
                                             GDate *date);
void        g_date_subtract_days            (GDate *date,
                                             guint n_days);
void        g_date_subtract_months          (GDate *date,
                                             guint n_months);
void        g_date_subtract_years           (GDate *date,
                                             guint n_years);
guint       g_date_sunday_week_of_year      (GDate *date);
guint8      g_date_sunday_weeks_in_year     (GDateYear year);
void        g_date_to_struct_tm             (GDate *date,
                                             struct tm *tm);
gboolean    g_date_valid                    (GDate *date);
gboolean    g_date_valid_day                (GDateDay day);
gboolean    g_date_valid_dmy                (GDateDay day,
                                             GDateMonth month,
                                             GDateYear year);
gboolean    g_date_valid_julian             (guint32 julian_date);
gboolean    g_date_valid_month              (GDateMonth month);
gboolean    g_date_valid_weekday            (GDateWeekday weekday);
gboolean    g_date_valid_year               (GDateYear year);
GDateWeekday g_date_weekday                 (GDate *date);
GDateYear   g_date_year                     (GDate *date);

Description

Details

struct GTimeVal

struct GTimeVal
{
  glong tv_sec;
  glong tv_usec;
};


g_get_current_time ()

void        g_get_current_time              (GTimeVal *result);

result : 


GTime

typedef gint32	GTime;

FIXME: Nothing to do with GTimer!!


struct GDate

struct GDate
{ 
  guint julian_days : 32; /* julian days representation - we use a
                           *  bitfield hoping that 64 bit platforms
                           *  will pack this whole struct in one big
                           *  int 
                           */

  guint julian : 1;    /* julian is valid */
  guint dmy    : 1;    /* dmy is valid */

  /* DMY representation */
  guint day    : 6;  
  guint month  : 4; 
  guint year   : 16; 
};


enum GDateDMY

typedef enum
{
  G_DATE_DAY   = 0,
  G_DATE_MONTH = 1,
  G_DATE_YEAR  = 2
} GDateDMY;


GDateDay

typedef guint8  GDateDay;   /* day of the month */


enum GDateMonth

typedef enum
{
  G_DATE_BAD_MONTH = 0,
  G_DATE_JANUARY   = 1,
  G_DATE_FEBRUARY  = 2,
  G_DATE_MARCH     = 3,
  G_DATE_APRIL     = 4,
  G_DATE_MAY       = 5,
  G_DATE_JUNE      = 6,
  G_DATE_JULY      = 7,
  G_DATE_AUGUST    = 8,
  G_DATE_SEPTEMBER = 9,
  G_DATE_OCTOBER   = 10,
  G_DATE_NOVEMBER  = 11,
  G_DATE_DECEMBER  = 12
} GDateMonth;


enum GDateWeekday

typedef enum
{
  G_DATE_BAD_WEEKDAY  = 0,
  G_DATE_MONDAY       = 1,
  G_DATE_TUESDAY      = 2,
  G_DATE_WEDNESDAY    = 3,
  G_DATE_THURSDAY     = 4,
  G_DATE_FRIDAY       = 5,
  G_DATE_SATURDAY     = 6,
  G_DATE_SUNDAY       = 7
} GDateWeekday;


GDateYear

typedef guint16 GDateYear;


G_DATE_BAD_DAY

#define G_DATE_BAD_DAY    0U


G_DATE_BAD_JULIAN

#define G_DATE_BAD_JULIAN 0U


G_DATE_BAD_YEAR

#define G_DATE_BAD_YEAR   0U


g_date_add_days ()

void        g_date_add_days                 (GDate *date,
                                             guint n_days);

date : 
n_days : 


g_date_add_months ()

void        g_date_add_months               (GDate *date,
                                             guint n_months);

date : 
n_months : 


g_date_add_years ()

void        g_date_add_years                (GDate *date,
                                             guint n_years);

date : 
n_years : 


g_date_clear ()

void        g_date_clear                    (GDate *date,
                                             guint n_dates);

date : 
n_dates : 


g_date_compare ()

gint        g_date_compare                  (GDate *lhs,
                                             GDate *rhs);

lhs : 
rhs : 
Returns : 


g_date_day ()

GDateDay    g_date_day                      (GDate *date);

date : 
Returns : 


g_date_day_of_year ()

guint       g_date_day_of_year              (GDate *date);

date : 
Returns : 


g_date_days_in_month ()

guint8      g_date_days_in_month            (GDateMonth month,
                                             GDateYear year);

month : 
year : 
Returns : 


g_date_free ()

void        g_date_free                     (GDate *date);

date : 


g_date_is_first_of_month ()

gboolean    g_date_is_first_of_month        (GDate *date);

date : 
Returns : 


g_date_is_last_of_month ()

gboolean    g_date_is_last_of_month         (GDate *date);

date : 
Returns : 


g_date_is_leap_year ()

gboolean    g_date_is_leap_year             (GDateYear year);

year : 
Returns : 


g_date_julian ()

guint32     g_date_julian                   (GDate *date);

date : 
Returns : 


g_date_monday_week_of_year ()

guint       g_date_monday_week_of_year      (GDate *date);

date : 
Returns : 


g_date_monday_weeks_in_year ()

guint8      g_date_monday_weeks_in_year     (GDateYear year);

year : 
Returns : 


g_date_month ()

GDateMonth  g_date_month                    (GDate *date);

date : 
Returns : 


g_date_new ()

GDate*      g_date_new                      (void);

Returns : 


g_date_new_dmy ()

GDate*      g_date_new_dmy                  (GDateDay day,
                                             GDateMonth month,
                                             GDateYear year);

day : 
month : 
year : 
Returns : 


g_date_new_julian ()

GDate*      g_date_new_julian               (guint32 julian_day);

julian_day : 
Returns : 


g_date_set_day ()

void        g_date_set_day                  (GDate *date,
                                             GDateDay day);

date : 
day : 


g_date_set_dmy ()

void        g_date_set_dmy                  (GDate *date,
                                             GDateDay day,
                                             GDateMonth month,
                                             GDateYear y);

date : 
day : 
month : 
y : 


g_date_set_julian ()

void        g_date_set_julian               (GDate *date,
                                             guint32 julian_date);

date : 
julian_date : 


g_date_set_month ()

void        g_date_set_month                (GDate *date,
                                             GDateMonth month);

date : 
month : 


g_date_set_parse ()

void        g_date_set_parse                (GDate *date,
                                             const gchar *str);

date : 
str : 


g_date_set_time ()

void        g_date_set_time                 (GDate *date,
                                             GTime time);

date : 
time : 


g_date_set_year ()

void        g_date_set_year                 (GDate *date,
                                             GDateYear year);

date : 
year : 


g_date_strftime ()

gsize       g_date_strftime                 (gchar *s,
                                             gsize slen,
                                             const gchar *format,
                                             GDate *date);

s : 
slen : 
format : 
date : 
Returns : 


g_date_subtract_days ()

void        g_date_subtract_days            (GDate *date,
                                             guint n_days);

date : 
n_days : 


g_date_subtract_months ()

void        g_date_subtract_months          (GDate *date,
                                             guint n_months);

date : 
n_months : 


g_date_subtract_years ()

void        g_date_subtract_years           (GDate *date,
                                             guint n_years);

date : 
n_years : 


g_date_sunday_week_of_year ()

guint       g_date_sunday_week_of_year      (GDate *date);

date : 
Returns : 


g_date_sunday_weeks_in_year ()

guint8      g_date_sunday_weeks_in_year     (GDateYear year);

year : 
Returns : 


g_date_to_struct_tm ()

void        g_date_to_struct_tm             (GDate *date,
                                             struct tm *tm);

date : 
tm : 


g_date_valid ()

gboolean    g_date_valid                    (GDate *date);

date : 
Returns : 


g_date_valid_day ()

gboolean    g_date_valid_day                (GDateDay day);

day : 
Returns : 


g_date_valid_dmy ()

gboolean    g_date_valid_dmy                (GDateDay day,
                                             GDateMonth month,
                                             GDateYear year);

day : 
month : 
year : 
Returns : 


g_date_valid_julian ()

gboolean    g_date_valid_julian             (guint32 julian_date);

julian_date : 
Returns : 


g_date_valid_month ()

gboolean    g_date_valid_month              (GDateMonth month);

month : 
Returns : 


g_date_valid_weekday ()

gboolean    g_date_valid_weekday            (GDateWeekday weekday);

weekday : 
Returns : 


g_date_valid_year ()

gboolean    g_date_valid_year               (GDateYear year);

year : 
Returns : 


g_date_weekday ()

GDateWeekday g_date_weekday                 (GDate *date);

date : 
Returns : 


g_date_year ()

GDateYear   g_date_year                     (GDate *date);

date : 
Returns :