From 41071737d02a92b64de0d83b3cd2c9d4cabecb37 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Fri, 5 Jun 2009 11:51:46 -0500 Subject: Add utility to convert SCTS to local/remote time --- unit/test-sms.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'unit') diff --git a/unit/test-sms.c b/unit/test-sms.c index d644cda0..6057076e 100644 --- a/unit/test-sms.c +++ b/unit/test-sms.c @@ -38,6 +38,10 @@ static const char *simple_submit = "0011000B916407281553F80000AA" static void print_scts(struct sms_scts *scts, const char *prefix) { + time_t ts; + struct tm remote; + char buf[128]; + g_print("%s: (YY-MM-DD) %02d-%02d-%02d\n", prefix, (int)scts->year, (int)scts->month, (int)scts->day); @@ -47,6 +51,18 @@ static void print_scts(struct sms_scts *scts, const char *prefix) g_print("%s: Timezone %d hours %d minutes\n", prefix, (int)scts->timezone / 4, (int)((abs(scts->timezone) % 4) * 15)); + + ts = sms_scts_to_time(scts, &remote); + + strftime(buf, 127, "%a, %d %b %Y %H:%M:%S %z", localtime(&ts)); + buf[127] = '\0'; + + g_print("local time: %s\n", buf); + + strftime(buf, 127, "%a, %d %b %Y %H:%M:%S %z", &remote); + buf[127] = '\0'; + + g_print("remote time: %s\n", buf); } static void print_vpf(enum sms_validity_period_format vpf, -- cgit v1.2.3