1
/* poppler-date.cc: glib interface to poppler
3
* Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2, or (at your option)
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
22
#include "poppler-date.h"
26
* @date: string to parse
27
* @timet: an uninitialized #time_t
29
* Parses a PDF format date string and converts it to a #time_t. Returns #FALSE
30
* if the parsing fails or the input string is not a valid PDF format date string
32
* Return value: #TRUE, if @timet was set
35
poppler_date_parse (const gchar *date,
38
gint year, mon, day, hour, min, sec, tz_hour, tz_minute;
43
/* See PDF Reference 1.3, Section 3.8.2 for PDF Date representation */
44
// TODO do something with the timezone information
45
if (!parseDateString (date, &year, &mon, &day, &hour, &min, &sec, &tz, &tz_hour, &tz_minute))
48
time.tm_year = year - 1900;
49
time.tm_mon = mon - 1;
56
time.tm_isdst = -1; /* 0 = DST off, 1 = DST on, -1 = don't know */
58
/* compute tm_wday and tm_yday and check date */
59
retval = mktime (&time);
60
if (retval == (time_t) - 1)