diff options
author | Ondrej Filip <feela@network.cz> | 2005-02-12 23:27:55 +0100 |
---|---|---|
committer | Ondrej Filip <feela@network.cz> | 2005-02-12 23:27:55 +0100 |
commit | 0d3effcf8ca3784c36ce6229343ddfd754e405dc (patch) | |
tree | b9e94e0fffe9123aeaffab3f074c39268d49f39b /sysdep | |
parent | 89ba9a18068dc83557e03c58bf280f4dc203271d (diff) | |
download | bird-0d3effcf8ca3784c36ce6229343ddfd754e405dc.tar bird-0d3effcf8ca3784c36ce6229343ddfd754e405dc.zip |
Time added in password management.
Diffstat (limited to 'sysdep')
-rw-r--r-- | sysdep/unix/io.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index f68763c..5ecc8ae 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -300,6 +300,30 @@ tm_shot(void) } /** + * tm_parse_datetime - parse a date and time + * @x: datetime string + * + * tm_parse_datetime() takes a textual representation of + * a date and time (dd-mm-yyyy hh:mm:ss) + * and converts it to the corresponding value of type &bird_clock_t. + */ +bird_clock_t +tm_parse_datetime(char *x) +{ + struct tm tm; + int n; + time_t t; + + if (sscanf(x, "%d-%d-%d %d:%d:%d%n", &tm.tm_mday, &tm.tm_mon, &tm.tm_year, &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &n) != 6 || x[n]) + return tm_parse_date(x); + tm.tm_mon--; + tm.tm_year -= 1900; + t = mktime(&tm); + if (t == (time_t) -1) + return 0; + return t; +} +/** * tm_parse_date - parse a date * @x: date string * |