Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
test_date.c File Reference
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include "gwlib/gwlib.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 64 of file test_date.c.

References date_parse_iso(), universaltime::day, get_and_set_debugs(), gwlib_init(), gwlib_shutdown(), universaltime::hour, info(), universaltime::minute, universaltime::month, octstr_create, octstr_destroy(), octstr_get_cstr, panic, universaltime::second, and universaltime::year.

65 {
66  Octstr *s;
67  struct universaltime ut;
68 
69  gwlib_init();
70 
71  get_and_set_debugs(argc, argv, NULL);
72 
73  s = octstr_create("2009-02-10T10:02:03");
74  if (date_parse_iso(&ut, s) == -1) {
75  panic(0, "date_parse_iso failed: %s", octstr_get_cstr(s));
76  }
77  info(0, "%s : %04ld-%02ld-%02ldT%02ld:%02ld:%02ld", octstr_get_cstr(s), ut.year, ut.month+1, ut.day, ut.hour, ut.minute, ut.second);
78  octstr_destroy(s);
79 
80  s = octstr_create("2009-02-10");
81  if (date_parse_iso(&ut, s) == -1) {
82  panic(0, "date_parse_iso failed: %s", octstr_get_cstr(s));
83  }
84  info(0, "%s : %04ld-%02ld-%02ldT%02ld:%02ld:%02ld", octstr_get_cstr(s), ut.year, ut.month+1, ut.day, ut.hour, ut.minute, ut.second);
85  octstr_destroy(s);
86 
87  s = octstr_create("20090210T10:02:03");
88  if (date_parse_iso(&ut, s) == -1) {
89  panic(0, "date_parse_iso failed: %s", octstr_get_cstr(s));
90  }
91  info(0, "%s : %04ld%02ld%02ldT%02ld:%02ld:%02ld", octstr_get_cstr(s), ut.year, ut.month+1, ut.day, ut.hour, ut.minute, ut.second);
92  octstr_destroy(s);
93 
94  s = octstr_create("20090210");
95  if (date_parse_iso(&ut, s) == -1) {
96  panic(0, "date_parse_iso failed: %s", octstr_get_cstr(s));
97  }
98  info(0, "%s : %04ld%02ld%02ldT%02ld:%02ld:%02ld", octstr_get_cstr(s), ut.year, ut.month+1, ut.day, ut.hour, ut.minute, ut.second);
99  octstr_destroy(s);
100 
101  gwlib_shutdown();
102  return 0;
103 }
void info(int err, const char *fmt,...)
Definition: log.c:636
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:322
#define octstr_create(cstr)
Definition: octstr.h:125
int date_parse_iso(struct universaltime *ut, Octstr *os)
Definition: date.c:227
Definition: octstr.c:118
#define panic
Definition: log.h:87
void gwlib_shutdown(void)
Definition: gwlib.c:94
void gwlib_init(void)
Definition: gwlib.c:78
int get_and_set_debugs(int argc, char **argv, int(*find_own)(int index, int argc, char **argv))
Definition: utils.c:626
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.