Provided by: jcal_0.5.1-0.2_amd64 bug

NAME

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

SYNOPSIS

       #include <time.h>

       char *jstrptime(const char *s, const char *format, struct jtm *jtm);

       Link with -ljalali

DESCRIPTION

       The  jstrptime()  function  is  the  converse  function to jstrftime(3) and converts the character string
       pointed to by s to values which are stored in the jtm structure pointed  to  by  jtm,  using  the  format
       specified  by  format.   Here  format  is  a character string that consists of field descriptors and text
       characters, reminiscent of scanf(3).  Each field descriptor consists of a % character followed by another
       character that specifies the replacement for the field descriptor.  All other characters  in  the  format
       string  must  have  a  matching  character  in  the  input  string.   There should be whitespace or other
       alphanumeric characters between any two field descriptors.

       The jstrptime() function processes the input string from left to right.  Each of the three possible input
       elements (whitespace, literal, or format) are handled one after  the  other.   If  the  input  cannot  be
       matched  to  the format string the function stops.  The remainder of the format and input strings are not
       processed.

       The supported input field descriptors are listed below.  In case a text string  (such  as  a  weekday  or
       month  name)  is  to  be matched, the comparison is case insensitive.  In case a number is to be matched,
       leading zeros are permitted but not required.

       %%     The % character.

       %a or %A or %h or %q
              The weekday name in abbreviated form or the full name.

       %b or %B
              The month name in abbreviated form or the full name.

       %d or %e
              The day of month (1-31).

       %H     The hour (0-23).

       %j     The day number in the year (1-366).

       %m     The month number (1-12).

       %M     The minute (0-59).

       %s     Seconds since UTC Epoch.

       %S     The second (0-59).

       %y     The year within century (0-99).  When a century is not otherwise specified, values  in  the  range
              19-99  refer  to  years  in the fourteenth century (1319-1399); values in the range 00-18 refer to
              years in the fifteenth century (1400-1418).

       %Y     The year, including century (for example, 1390).

       The broken-down jalali time structure jtm is defined in <jtime.h> as follows:

           struct jtm {
               int tm_sec;        /* seconds */
               int tm_min;        /* minutes */
               int tm_hour;       /* hours */
               int tm_mday;       /* day of the month */
               int tm_mon;        /* month */
               int tm_year;       /* year */
               int tm_wday;       /* day of the week */
               int tm_yday;       /* day in the year */
               int tm_isdst;      /* daylight saving time */
           };

RETURN VALUE

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

CONFORMING TO

       C99.

NOTES

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

EXAMPLE

       The following example demonstrates the use of jstrptime(3) and jstrftime(3).

       #include <stdio.h>
       #include <stdlib.h>
       #include <string.h>
       #include <time.h>
       #include <jalali.h>
       #include <jtime.h>

       int
       main(void)
       {
           struct jtm tm;
           char buf[255];

           memset(&jtm, 0, sizeof(struct jtm));
           jstrptime("1390-03-17 08:33:01", "%Y-%m-%d %H:%M:%S", &jtm);
           jstrftime(buf, sizeof(buf), "%d %b %Y %H:%M", &jtm);
           puts(buf);
           exit(EXIT_SUCCESS);
       }

SEE ALSO

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

COLOPHON

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

AUTHOR

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

REPORTING BUGS

       Report libjalali bugs to <ghassemi@ftml.net>

       libjalali home page: <http://savannah.nongnu.org/projects/jcal/>

COPYRIGHT

       Copyright (C) 2011 Ashkan Ghassemi.

       License LGPLv3+: GNU LGPL version 3 or later <http://gnu.org/licenses/lgpl.html>.  This is free software:
       you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

GNU                                                2011-05-28                                       JSTRPTIME(3)