~ubuntu-branches/ubuntu/precise/sitecopy/precise

« back to all changes in this revision

Viewing changes to lib/neon/ne_dates.c

  • Committer: Bazaar Package Importer
  • Author(s): Sandro Tosi
  • Date: 2008-07-22 07:31:05 UTC
  • mfrom: (1.1.4 upstream) (4.1.7 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080722073105-cbqs1hnc2wvqejfd
Tags: 1:0.16.6-1
* New upstream release
  - fix a crash with progress bar enabled; Closes: #486378
* debian/control
  - set myself as maintainer, Kartik as uploader
  - set Vcs-{Browser,Git} fields
  - bump Standards-Version to 3.8.0
    + debian/README.source added
  - added DM-Upload-Allowed flag
* debian/patches/05_libneon27_transition.dpatch
  - removed since merged upstream
* debian/copyrightdebian/copyright
  - updated upstream email and copyright years
* debian/patches/10_bts410703_preserve_storage_files_sigint.dpatch
  - added to preserve storage files if SIGINT (Ctrl+C) is sent to sitecopy;
    thanks to Andreas Henriksson for the patch; Closes: #410703

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* 
2
2
   Date manipulation routines
3
 
   Copyright (C) 1999-2005, Joe Orton <joe@manyfish.co.uk>
 
3
   Copyright (C) 1999-2006, Joe Orton <joe@manyfish.co.uk>
4
4
   Copyright (C) 2004 Jiang Lei <tristone@deluxe.ocn.ne.jp>
5
5
 
6
6
   This library is free software; you can redistribute it and/or
56
56
/* asctime: Wed Jun 30 21:49:08 1993 */
57
57
#define ASCTIME_FORMAT "%3s %3s %2d %2d:%2d:%2d %4d"
58
58
 
59
 
static const char *const rfc1123_weekdays[7] = { 
 
59
static const char rfc1123_weekdays[7][4] = { 
60
60
    "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" 
61
61
};
62
 
static const char *const short_months[12] = { 
 
62
static const char short_months[12][4] = { 
63
63
    "Jan", "Feb", "Mar", "Apr", "May", "Jun",
64
64
    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
65
65
};
70
70
#define GMTOFF(t) ((t).__tm_gmtoff)
71
71
#elif defined(WIN32)
72
72
#define GMTOFF(t) (gmt_to_local_win32())
 
73
#elif defined(HAVE_TIMEZONE)
 
74
/* FIXME: the following assumes fixed dst offset of 1 hour */
 
75
#define GMTOFF(t) (-timezone + ((t).tm_isdst > 0 ? 3600 : 0))
73
76
#else
74
77
/* FIXME: work out the offset anyway. */
75
78
#define GMTOFF(t) (0)
122
125
    double sec;
123
126
    off_t fix;
124
127
    int n;
 
128
    time_t result;
125
129
 
126
130
    /*  it goes: ISO8601: 2001-01-01T12:30:00+03:30 */
127
131
    if ((n = sscanf(date, ISO8601_FORMAT_P,
154
158
    gmt.tm_isdst = -1;
155
159
    gmt.tm_mon--;
156
160
 
157
 
    return mktime(&gmt) + fix + GMTOFF(gmt);
 
161
    result = mktime(&gmt) + fix;
 
162
    return result + GMTOFF(gmt);
158
163
}
159
164
 
160
165
/* Takes an RFC1123-formatted date string and returns the time_t.
164
169
    struct tm gmt = {0};
165
170
    char wkday[4], mon[4];
166
171
    int n;
 
172
    time_t result;
 
173
    
167
174
/*  it goes: Sun, 06 Nov 1994 08:49:37 GMT */
168
175
    n = sscanf(date, RFC1123_FORMAT,
169
176
            wkday, &gmt.tm_mday, mon, &gmt.tm_year, &gmt.tm_hour,
177
184
     * since the mktime will then fail */
178
185
    gmt.tm_mon = n;
179
186
    gmt.tm_isdst = -1;
180
 
    return mktime(&gmt) + GMTOFF(gmt);
 
187
    result = mktime(&gmt);
 
188
    return result + GMTOFF(gmt);
181
189
}
182
190
 
183
191
/* Takes a string containing a RFC1036-style date and returns the time_t */
186
194
    struct tm gmt = {0};
187
195
    int n;
188
196
    char wkday[11], mon[4];
 
197
    time_t result;
 
198
 
189
199
    /* RFC850/1036 style dates: Sunday, 06-Nov-94 08:49:37 GMT */
190
200
    n = sscanf(date, RFC1036_FORMAT,
191
201
                wkday, &gmt.tm_mday, mon, &gmt.tm_year,
207
217
 
208
218
    gmt.tm_mon = n;
209
219
    gmt.tm_isdst = -1;
210
 
    return mktime(&gmt) + GMTOFF(gmt);
 
220
    result = mktime(&gmt);
 
221
    return result + GMTOFF(gmt);
211
222
}
212
223
 
213
224
 
219
230
    struct tm gmt = {0};
220
231
    int n;
221
232
    char wkday[4], mon[4];
 
233
    time_t result;
 
234
 
222
235
    n = sscanf(date, ASCTIME_FORMAT,
223
236
                wkday, mon, &gmt.tm_mday, 
224
237
                &gmt.tm_hour, &gmt.tm_min, &gmt.tm_sec,
231
244
     * since the mktime will then fail */
232
245
    gmt.tm_mon = n;
233
246
    gmt.tm_isdst = -1;
234
 
    return mktime(&gmt) + GMTOFF(gmt);
 
247
    result = mktime(&gmt);
 
248
    return result + GMTOFF(gmt);
235
249
}
236
250
 
237
251
/* HTTP-date parser */