~ubuntu-branches/ubuntu/natty/luatex/natty

« back to all changes in this revision

Viewing changes to source/libs/poppler/poppler-0.12.4/glib/poppler-date.cc

  • Committer: Package Import Robot
  • Author(s): Norbert Preining
  • Date: 2010-12-13 23:22:59 UTC
  • mfrom: (0.2.1) (1.5.4) (4.3.12 experimental)
  • Revision ID: package-import@ubuntu.com-20101213232259-nqq2mq5z5x6qldw3
Tags: 0.65.0-1
* new upstream release
* ship two source packages as they are distributed by upstream, only
  renamed to match source package requirements. Fix debian/rules
  to install the manual pdf from the right place

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* poppler-date.cc: glib interface to poppler
 
2
 *
 
3
 * Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
 
4
 *
 
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)
 
8
 * any later version.
 
9
 *
 
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.
 
14
 *
 
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.
 
18
 */
 
19
 
 
20
#include <DateInfo.h>
 
21
 
 
22
#include "poppler-date.h"
 
23
 
 
24
/**
 
25
 * poppler_date_parse:
 
26
 * @date: string to parse
 
27
 * @timet: an uninitialized #time_t
 
28
 *
 
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
 
31
 *
 
32
 * Return value: #TRUE, if @timet was set
 
33
 **/
 
34
gboolean
 
35
poppler_date_parse (const gchar *date,
 
36
                    time_t      *timet)
 
37
{
 
38
  gint year, mon, day, hour, min, sec, tz_hour, tz_minute;
 
39
  gchar tz;
 
40
  struct tm time;
 
41
  time_t retval;
 
42
  
 
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))
 
46
    return FALSE;
 
47
        
 
48
  time.tm_year = year - 1900;
 
49
  time.tm_mon = mon - 1;
 
50
  time.tm_mday = day;
 
51
  time.tm_hour = hour;
 
52
  time.tm_min = min;
 
53
  time.tm_sec = sec;
 
54
  time.tm_wday = -1;
 
55
  time.tm_yday = -1;
 
56
  time.tm_isdst = -1; /* 0 = DST off, 1 = DST on, -1 = don't know */
 
57
 
 
58
  /* compute tm_wday and tm_yday and check date */
 
59
  retval = mktime (&time);
 
60
  if (retval == (time_t) - 1)
 
61
    return FALSE;
 
62
    
 
63
  *timet = retval;
 
64
 
 
65
  return TRUE;  
 
66
}