File: strptime.xs

package info (click to toggle)
libposix-strptime-perl 0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 200 kB
  • ctags: 422
  • sloc: perl: 32; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 807 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#include "ppport.h"

#include <time.h>

#define POSIX_STRPTIME_SET(field) \
  { \
    if (field == -1) { \
        XPUSHs(&PL_sv_undef); \
    } \
    else { \
        mXPUSHi(field); \
    } \
  } \


MODULE = POSIX::strptime		PACKAGE = POSIX::strptime

void
strptime(input, format)
    const char *input
    const char *format
   PREINIT:
     struct tm tm_t  = { -1,-1,-1,-1,-1,-1,-1,-1 };
   PPCODE:
     strptime(input, format, &tm_t);
     POSIX_STRPTIME_SET(tm_t.tm_sec);
     POSIX_STRPTIME_SET(tm_t.tm_min);
     POSIX_STRPTIME_SET(tm_t.tm_hour);
     POSIX_STRPTIME_SET(tm_t.tm_mday);
     POSIX_STRPTIME_SET(tm_t.tm_mon);
     POSIX_STRPTIME_SET(tm_t.tm_year);
     POSIX_STRPTIME_SET(tm_t.tm_wday);
     POSIX_STRPTIME_SET(tm_t.tm_yday);