kputil

kputil —

Synopsis




#define     NOT_NULL                        (x)
enum        KPTod;
gboolean    kp_date_valid                   (KPDate *date);
void        kp_date_set_time                (KPDate *date,
                                             GTime time_);
KPDate*     kp_date_new_dmy                 (guint d,
                                             guint m,
                                             guint y);
void        kp_date_free                    (KPDate *date);
gboolean    kp_date_to_locale_string        (KPDate *date,
                                             gchar *buf,
                                             size_t len);
gboolean    kp_date_dmy_to_locale_string    (guint d,
                                             guint m,
                                             guint y,
                                             gchar *buf,
                                             size_t len);
void        kp_date_from_gdate              (KPDate *date,
                                             GDate *gdate);
void        kp_time_set_hms                 (KPTime *t,
                                             guint h,
                                             guint m,
                                             guint s);
void        kp_date_set_dmy                 (KPDate *date,
                                             guint d,
                                             guint m,
                                             guint y);
guint       kp_date_get_iso8061_week_of_year
                                            (KPDate *date);
void        kp_time_set_tod                 (KPTime *t,
                                             KPTod tod);
gboolean    kp_time_is_tod                  (KPTime *t,
                                             KPTod *tod);
gchar*      kp_time_tod_to_string           (KPTime *time);
gchar*      kp_date_seconds_to_string       (gdouble sec);
gchar*      kp_date_mseconds_to_std_string  (guint32 msec);
gint32      kp_duration_str_to_ms           (const gchar *time_str);
gboolean    kp_is_valid_date_str            (const gchar *date_str);
gboolean    kp_is_valid_time_str            (const gchar *time_str);
gboolean    kp_is_valid_number              (const gchar *possible_number);
gdouble     kp_number                       (const gchar*);
gdouble     kp_is_valid_duration_entry_str  (const gchar *time_str);
GValue*     kp_g_value_from_string          (const gchar *string);
gchar*      kp_g_value_to_string            (const GValue *value);
guint       kp_get_month_len                (guint m,
                                             gboolean is_leap);
gboolean    kp_leap                         (guint year);
gboolean    kp_week_of_year                 (guint *week,
                                             guint *year,
                                             guint mm,
                                             guint dd);
glong       kp_calc_days                    (guint year,
                                             guint mm,
                                             guint dd);
guint       kp_day_of_week                  (guint year,
                                             guint mm,
                                             guint dd);
glong       kp_dates_difference             (guint year1,
                                             guint mm1,
                                             guint dd1,
                                             guint year2,
                                             guint mm2,
                                             guint dd2);
guint       kp_weeks_in_year                (guint year);
void        kp_print_debug_string           (const gchar *file,
                                             const gchar *function,
                                             guint line,
                                             const gchar *message,
                                             ...);
gint        kp_get_month_num                (const gchar *m);
const gchar* kp_get_month_name              (guint m);
guint       kp_month_num_by_year_day_number (guint day_num,
                                             gboolean is_leap);
void        kp_autoscale_axis               (gdouble *min,
                                             gdouble *max);
#define     KP_TAG_MATCH                    (node,tagname)
#define     kp_debug                        (...)

Description

Details

NOT_NULL()

#define NOT_NULL(x) ((x) ? (x) : "")

x :

enum KPTod

typedef enum {
  KP_TOD_MORNING,
  KP_TOD_NOON,
  KP_TOD_AFTERNOON,
  KP_TOD_EVENING,
} KPTod;


kp_date_valid ()

gboolean    kp_date_valid                   (KPDate *date);

Checks if this DMY is valid julian day.

date : A KPDate
Returns : TRUE if date is valid and FALSE otherwise.

kp_date_set_time ()

void        kp_date_set_time                (KPDate *date,
                                             GTime time_);

Used to create

date : KPDate
time_ : time value, just like time_t

kp_date_new_dmy ()

KPDate*     kp_date_new_dmy                 (guint d,
                                             guint m,
                                             guint y);

Just create a new KPDate.

d : Day
m : Month (1-12)
y : Year
Returns : New KPDate

kp_date_free ()

void        kp_date_free                    (KPDate *date);

Free the memory used by date.

date : A KPDate

kp_date_to_locale_string ()

gboolean    kp_date_to_locale_string        (KPDate *date,
                                             gchar *buf,
                                             size_t len);

date :
buf :
len :
Returns :

kp_date_dmy_to_locale_string ()

gboolean    kp_date_dmy_to_locale_string    (guint d,
                                             guint m,
                                             guint y,
                                             gchar *buf,
                                             size_t len);

d :
m :
y :
buf :
len :
Returns :

kp_date_from_gdate ()

void        kp_date_from_gdate              (KPDate *date,
                                             GDate *gdate);

date :
gdate :

kp_time_set_hms ()

void        kp_time_set_hms                 (KPTime *t,
                                             guint h,
                                             guint m,
                                             guint s);

t :
h :
m :
s :

kp_date_set_dmy ()

void        kp_date_set_dmy                 (KPDate *date,
                                             guint d,
                                             guint m,
                                             guint y);

date :
d :
m :
y :

kp_date_get_iso8061_week_of_year ()

guint       kp_date_get_iso8061_week_of_year
                                            (KPDate *date);

date :
Returns :

kp_time_set_tod ()

void        kp_time_set_tod                 (KPTime *t,
                                             KPTod tod);

t :
tod :

kp_time_is_tod ()

gboolean    kp_time_is_tod                  (KPTime *t,
                                             KPTod *tod);

t :
tod :
Returns :

kp_time_tod_to_string ()

gchar*      kp_time_tod_to_string           (KPTime *time);

Turns tod to string presentation if the time is one of the tods recognized.

time : A KPTime
Returns : Newly-allocated string or NULL

kp_date_seconds_to_string ()

gchar*      kp_date_seconds_to_string       (gdouble sec);

sec :
Returns :

kp_date_mseconds_to_std_string ()

gchar*      kp_date_mseconds_to_std_string  (guint32 msec);

msec :
Returns :

kp_duration_str_to_ms ()

gint32      kp_duration_str_to_ms           (const gchar *time_str);

time_str :
Returns :

kp_is_valid_date_str ()

gboolean    kp_is_valid_date_str            (const gchar *date_str);

date_str :
Returns :

kp_is_valid_time_str ()

gboolean    kp_is_valid_time_str            (const gchar *time_str);

time_str :
Returns :

kp_is_valid_number ()

gboolean    kp_is_valid_number              (const gchar *possible_number);

Find out if the string contains some numeric data.

possible_number : String that may contain a valid numeric value
Returns : TRUE if string contains numeric data only and FALSE otherwise.

kp_number ()

gdouble     kp_number                       (const gchar*);

Try to parse a string to a double.

Param1 :
Returns : The double value if possible_number is valid and -1.0 otherwise.

kp_is_valid_duration_entry_str ()

gdouble     kp_is_valid_duration_entry_str  (const gchar *time_str);

time_str :
Returns :

kp_g_value_from_string ()

GValue*     kp_g_value_from_string          (const gchar *string);

Tries to guess what kind of value that string represents and allocates space for the structure and initializes it with the correct value.

string : A string that contains some value
Returns : A pointer to GValue that must be freed.

kp_g_value_to_string ()

gchar*      kp_g_value_to_string            (const GValue *value);

Transform a GValue to a string presentation to show it to the user for example.

value : Pointer to GValue that is initialized
Returns : A newly-allocated string that must be freed.

kp_get_month_len ()

guint       kp_get_month_len                (guint m,
                                             gboolean is_leap);

Get number of days in the month.

m : Number of the month (0-11)
is_leap : TRUE if the year which the month is in, is a leap year
Returns : Number of the days or 0 if month number is invalid.

kp_leap ()

gboolean    kp_leap                         (guint year);

year :
Returns :

kp_week_of_year ()

gboolean    kp_week_of_year                 (guint *week,
                                             guint *year,
                                             guint mm,
                                             guint dd);

week :
year :
mm :
dd :
Returns :

kp_calc_days ()

glong       kp_calc_days                    (guint year,
                                             guint mm,
                                             guint dd);

year :
mm :
dd :
Returns :

kp_day_of_week ()

guint       kp_day_of_week                  (guint year,
                                             guint mm,
                                             guint dd);

year :
mm :
dd :
Returns :

kp_dates_difference ()

glong       kp_dates_difference             (guint year1,
                                             guint mm1,
                                             guint dd1,
                                             guint year2,
                                             guint mm2,
                                             guint dd2);

year1 :
mm1 :
dd1 :
year2 :
mm2 :
dd2 :
Returns :

kp_weeks_in_year ()

guint       kp_weeks_in_year                (guint year);

year :
Returns :

kp_print_debug_string ()

void        kp_print_debug_string           (const gchar *file,
                                             const gchar *function,
                                             guint line,
                                             const gchar *message,
                                             ...);

file :
function :
line :
message :
... :

kp_get_month_num ()

gint        kp_get_month_num                (const gchar *m);

Get number of the month.

m : localized month name.
Returns : The number of the month between 0 and 11 or -1 if the month is invalid.

kp_get_month_name ()

const gchar* kp_get_month_name              (guint m);

Get localized month name.

m : month number between 0 and 11
Returns : Static string that must not be freed or NULL if m is invalid.

kp_month_num_by_year_day_number ()

guint       kp_month_num_by_year_day_number (guint day_num,
                                             gboolean is_leap);

Return the month that some day number is in.

day_num : Number of day between 1-366
is_leap : TRUE if the year is a leap year and FALSE otherwise
Returns : Month number between 1 and 12 or 0 if params are invalid.

kp_autoscale_axis ()

void        kp_autoscale_axis               (gdouble *min,
                                             gdouble *max);

min :
max :

KP_TAG_MATCH()

#define         KP_TAG_MATCH(node,tagname)  (xmlStrcasecmp(((xmlNodePtr)node)->name,(xmlChar *)tagname) == 0)

node :
tagname :

kp_debug()

#define     kp_debug(...)

... :
... :
... :
... :
... :
... :
... :
... :