aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-time-utils.h
blob: f6d85df5acba6f9e76eca4a75eedb1ee2e4fc5d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Time utility functions
 *
 * Author:
 *   Damon Chaplin (damon@ximian.com)
 *
 * (C) 2001 Ximian, Inc.
 */

#ifndef E_TIME_UTILS
#define E_TIME_UTILS

#include <time.h>
#include <glib.h>

typedef enum {
    E_TIME_PARSE_OK,
    E_TIME_PARSE_NONE,
    E_TIME_PARSE_INVALID
} ETimeParseStatus;

/* Tries to parse a string containing a date and time. */
ETimeParseStatus e_time_parse_date_and_time (const char *value,
                         struct tm  *result);

/* Tries to parse a string containing a date. */
ETimeParseStatus e_time_parse_date      (const char *value,
                         struct tm  *result);

/* Tries to parse a string containing a time. */
ETimeParseStatus e_time_parse_time      (const char *value,
                         struct tm  *result);

/* Turns a struct tm into a string like "Wed  3/12/00 12:00:00 AM". */
void e_time_format_date_and_time        (struct tm  *date_tm,
                         gboolean    use_24_hour_format,
                         gboolean    show_midnight,
                         gboolean    show_zero_seconds,
                         char       *buffer,
                         int         buffer_size);

/* Formats a time from a struct tm, e.g. "01:59 PM". */
void e_time_format_time             (struct tm  *date_tm,
                         gboolean    use_24_hour_format,
                         gboolean    show_zero_seconds,
                         char       *buffer,
                         int         buffer_size);




#endif /* E_TIME_UTILS */