~ubuntu-branches/ubuntu/trusty/irssi-plugin-xmpp/trusty

« back to all changes in this revision

Viewing changes to src/core/xep/datetime.c

  • Committer: Package Import Robot
  • Author(s): Florian Schlichting, Florian Schlichting
  • Date: 2014-01-03 00:25:20 UTC
  • mfrom: (2.2.7 sid)
  • Revision ID: package-import@ubuntu.com-20140103002520-4ztm9phbq47vn4bl
Tags: 0.52+git20140102-1
[ Florian Schlichting ]
* Import Upstream version 0.52+git20140102
* Add VCS-* fields for collab-maint on alioth
* Add upstream git URL to Source field in debian/copyright
* Drop patches plucked from upstream CVS
* Refresh hardening.patch (offset, drop hunk fixed upstream)
* Provide xmpp-admin.pl script by Seth Difley
* Add GTalk-MUC-support.patch, plucked from github/freemandrew
* Add support for XMPP-PGP, plucked from github/singpolyma
* New useless-dependency-on-libidn.patch, to fix a lintian warning
* Declare compliance with Debian Policy 3.9.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * $Id: datetime.c,v 1.3 2009/06/03 15:14:15 cdidier Exp $
3
 
 *
4
2
 * Copyright (C) 2009 Colin DIDIER
5
3
 *
6
4
 * This program is free software; you can redistribute it and/or modify
32
30
 
33
31
#define FORMAT  "%Y-%m-%dT%T"
34
32
 
 
33
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
 
34
 
35
35
static long
36
36
parse_timezone(const char *tz)
37
37
{
38
 
        const char *rfc822_timezones[26][4] = {
 
38
        const char *rfc822_timezones[][4] = {
39
39
                { "M", NULL },                  /* UTC-12 */
40
40
                { "L", NULL },
41
41
                { "K", NULL },
61
61
                { "W", NULL },
62
62
                { "X", NULL },
63
63
                { "Y", NULL },                  /* UTC+12 */
64
 
                { NULL }
 
64
                { NULL },
65
65
        };
66
 
        long i, j;
 
66
        unsigned int i, j;
67
67
 
68
68
        if ((*tz == '+' || *tz == '-') && strlen(tz) == 5) {
69
69
                i = atoi(tz);
70
70
                return ((i/100)*60 + i%100) * 60;
71
71
        }
72
 
        for (i = 0; rfc822_timezones[i] != NULL; ++i)
 
72
        for (i = 0; i < nitems(rfc822_timezones); ++i)
73
73
                for (j = 0; rfc822_timezones[i][j] != NULL; ++j)
74
74
                        if (strcmp(rfc822_timezones[i][j], tz) == 0)
75
75
                                return (i - 12) * 3600;
88
88
                return (time_t)-1;
89
89
        /* ignore fractional second addendum */
90
90
        if (*s++ == '.')
91
 
                while (isdigit(*s++));
 
91
                while (isdigit(*s)) s++;
92
92
        tm.tm_isdst = -1;
93
93
        offset = *s != '\0' ? parse_timezone(s) : 0;
94
94
        return mktime(&tm) - offset;