User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

strptime [2009/06/14 20:54] (current)
Line 1: Line 1:
 +# $EPIC: strptime.txt,​v 1.1 2009/06/14 20:54:44 zwhite Exp $
 +$__strptime__("<​format>"​ <​string>​)
 +   * If the <​format>​ argument is omitted the empty string is returned.
 +   * If the <​format>​ argument is invalid the empty string is returned.
 +   * If the <​format>​ argument does not match the <​string>​ provided the empty string is returned.
 +   * If your <​format>​ is incomplete (does not describe a complete day and time) -1 is returned.
 +   * If your <​string>​ describes a time which can not be described by a time_t -1 is returned.
 +   * The first argument is a dword describing (in strftime(3) format) what format your human-readable string is in.
 +   * The rest of the argument(s) are taken as a string which matches <​format>​.
 +   * The return value of the function is the specified time converted into a unix timestamp.
 +   * Avoid using system-specific strftime(3) formats for portability reasons.
 +You should refer to your system'​s strftime man page (``man 3 strftime''​)
 +for exact details of what a strftime format looks like, because describing
 +them is beyond the scope of a help file. =)  But this function is very
 +useful for converting timestamps in different formats into a unix timestamp.
 +The behavior of strptime in epic is highly dependent upon the strptime(3)
 +implementation of the system it is running on. If you intend to use this
 +function in portable scripts you should avoid the use of system-specific
 +format strings.
 +On systems with a 32 bit time_t this function is only practical for describing
 +dates between Fri Dec 13 20:45:52 1901 and Tue Jan 19 03:14:07 2038.
 +The number of seconds since the epoch, which is typically 1970 Jan 1, 00:00 UTC.
 +$strptime("​%Y-%m-%d %T" 1985-10-26 01:24:00) might return "​499137840"​
 +$strptime("​%a %b %d %T %Y" Sun Jun 14 18:27:10 2009) might return "​1245004030"​
 +$strptime("​%Y-%m-%d"​ 1992-04-26) might return "​-1"​
 +$strptime("​%H:​%M:​%S"​ 16:00:00) might return "​-1"​
 +This function first appeared in epic5-0.3.6.
strptime.txt ยท Last modified: 2009/06/14 20:54 (external edit)