1
2JSTRPTIME(3)                   libjalali Manual                   JSTRPTIME(3)
3
4
5

NAME

7       jstrptime  - convert a string representation of jalali date and time to
8       a jalali time jtm structure
9

SYNOPSIS

11       #include <time.h>
12
13       char *jstrptime(const char *s, const char *format, struct jtm *jtm);
14
15       Link with -ljalali
16

DESCRIPTION

18       The jstrptime() function is the converse function to  jstrftime(3)  and
19       converts  the  character  string  pointed  to  by s to values which are
20       stored in the jtm structure pointed to by jtm, using the format  speci‐
21       fied  by  format.   Here  format is a character string that consists of
22       field descriptors and text characters, reminiscent of  scanf(3).   Each
23       field  descriptor consists of a % character followed by another charac‐
24       ter that specifies the replacement for the field descriptor.  All other
25       characters  in  the format string must have a matching character in the
26       input string.  There should be whitespace or other alphanumeric charac‐
27       ters between any two field descriptors.
28
29       The jstrptime() function processes the input string from left to right.
30       Each of the three possible input elements (whitespace, literal, or for‐
31       mat)  are  handled one after the other.  If the input cannot be matched
32       to the format string the function stops.  The remainder of  the  format
33       and input strings are not processed.
34
35       The supported input field descriptors are listed below.  In case a text
36       string (such as a weekday or month name) is to be matched, the compari‐
37       son  is  case  insensitive.  In case a number is to be matched, leading
38       zeros are permitted but not required.
39
40       %%     The % character.
41
42       %a or %A or %h or %q
43              The weekday name in abbreviated form or the full name.
44
45       %b or %B
46              The month name in abbreviated form or the full name.
47
48       %d or %e
49              The day of month (1-31).
50
51       %H     The hour (0-23).
52
53       %j     The day number in the year (1-366).
54
55       %m     The month number (1-12).
56
57       %M     The minute (0-59).
58
59       %s     Seconds since UTC Epoch.
60
61       %S     The second (0-59).
62
63       %y     The year within century (0-99).  When a century is not otherwise
64              specified, values in the range 19-99 refer to years in the four‐
65              teenth century (1319-1399); values in the range 00-18  refer  to
66              years in the fifteenth century (1400-1418).
67
68       %Y     The year, including century (for example, 1390).
69
70       The  broken-down  jalali  time structure jtm is defined in <jtime.h> as
71       follows:
72
73           struct jtm {
74               int tm_sec;        /* seconds */
75               int tm_min;        /* minutes */
76               int tm_hour;       /* hours */
77               int tm_mday;       /* day of the month */
78               int tm_mon;        /* month */
79               int tm_year;       /* year */
80               int tm_wday;       /* day of the week */
81               int tm_yday;       /* day in the year */
82               int tm_isdst;      /* daylight saving time */
83           };
84

RETURN VALUE

86       The return value of the function is a pointer to  the  first  character
87       not processed in this function call.  In case the input string contains
88       more characters than required by the format  string  the  return  value
89       points  right  after  the  last  consumed input character.  In case the
90       whole input string is consumed the return value points to the null byte
91       at  the  end  of  the string.  If jstrptime() fails to match all of the
92       format string and therefore an  error  occurred  the  function  returns
93       NULL.
94

CONFORMING TO

96       C99.
97

NOTES

99       In principle, this function does not initialize jtm but only stores the
100       values specified.  This means that jtm should be initialized before the
101       call.   libjalali  does not touch those fields which are not explicitly
102       specified.
103
104

EXAMPLE

106       The following example demonstrates the use of jstrptime(3)  and  jstrf‐
107       time(3).
108
109       #include <stdio.h>
110       #include <stdlib.h>
111       #include <string.h>
112       #include <time.h>
113       #include <jalali.h>
114       #include <jtime.h>
115
116       int
117       main(void)
118       {
119           struct jtm tm;
120           char buf[255];
121
122           memset(&jtm, 0, sizeof(struct jtm));
123           jstrptime("1390-03-17 08:33:01", "%Y-%m-%d %H:%M:%S", &jtm);
124           jstrftime(buf, sizeof(buf), "%d %b %Y %H:%M", &jtm);
125           puts(buf);
126           exit(EXIT_SUCCESS);
127       }
128

SEE ALSO

130       time(2),   jdate(1),   jcal(1),   getdate(3),  scanf(3),  jstrftime(3),
131       jctime(3), feature_test_macros(7)
132

COLOPHON

134       This page is part of release 0.2 of the libjalali man-pages
135

AUTHOR

137       Written by Ashkan Ghassemi. <ghassemi@ftml.net>
138

REPORTING BUGS

140       Report libjalali bugs to <ghassemi@ftml.net>
141
142       libjalali home page: <http://savannah.nongnu.org/projects/jcal/>
143
145       Copyright (C) 2011 Ashkan Ghassemi.
146
147       License    LGPLv3+:     GNU     LGPL     version     3     or     later
148       <http://gnu.org/licenses/lgpl.html>.   This  is  free software: you are
149       free to change and redistribute it. There is NO WARRANTY, to the extent
150       permitted by law.
151
152
153
154GNU                               2011-05-28                      JSTRPTIME(3)
Impressum