#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "../command.h"
Go to the source code of this file.
Defines | |
#define | _DAY_SEC (24L * 60L * 60L) |
#define | _YEAR_SEC (365L * _DAY_SEC) |
#define | _FOUR_YEAR_SEC (1461L * _DAY_SEC) |
#define | _BASE_DOW 4 |
#define | _BASE_YEAR 70L |
#define | _MAX_YEAR 138L |
#define | _LEAP_YEAR_ADJUST 17L |
#define | ChkAdd(dest, src1, src2) |
#define | ChkMul(dest, src1, src2) ( src1 ? (dest/src1 != src2) : 0 ) |
#define | MONTH_NAME_LEN 9 |
#define | WEEK_DAY_NAME_LEN 9 |
#define | NOCOMMAND(XXX) |
#define | TIMEFUN(NAME, FIELD) |
#define | TAKE_ARGUMENT(x) |
#define | TIMEFUN(XXX, YYY) |
Functions | |
static struct tm * | mygmtime (time_t *timp, struct tm *ptb) |
static long | mygmktime (struct tm *tb) |
static long | TimeDifference (void) |
if (CONVERT2ZCHAR(vFormatString==NULL) | |
if (vTimeValue) | |
memcpy (STRINGVALUE(RESULT), pszFormatString, strlen(pszFormatString)) | |
LONGVALUE (RESULT) | |
if (NODE nItem==0) | |
if (memory_IsUndef(vTime)) | |
if (nItem==0) | |
if (memory_IsUndef(vTime)||memory_IsUndef(vOffset)) | |
if (pGmTime->tm_mday > 28 &&pGmTime->tm_mon==1 &&(pGmTime->tm_year%4)) pGmTime->tm_mday = 28 | |
if (pGmTime->tm_mday==31 &&(pGmTime->tm_mon==3||pGmTime->tm_mon==5||pGmTime->tm_mon==7||pGmTime->tm_mon==8||pGmTime->tm_mon==10)) pGmTime->tm_mday | |
if (pGmTime->tm_mday > 29 &&pGmTime->tm_mon==1) pGmTime->tm_mday | |
TIMEFUN (ADDSECOND, 1) | |
Variables | |
static int | _lpdays [] = { -1, 30, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 } |
static int | _days [] = { -1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364 } |
static char * | MonthName [] |
static char * | WeekDayName [] |
VARIABLE | vFormatString |
VARIABLE | vTimeValue |
time_t | lTimeValue |
NODE | nItem |
char * | pszFormatString |
tm * | pGmTime |
tm | GmTime |
char * | s |
char * | r |
char | szNumberBuffer [5] |
int | hour |
int | len |
USE_CALLER_MORTALS | |
nItem = PARAMETERLIST | |
vFormatString = CONVERT2STRING(_EVALUATEEXPRESSION(CAR(nItem))) | |
ASSERTOKE | |
else | vTimeValue = NULL |
RESULT = NEWMORTALSTRING(strlen(pszFormatString)) | |
END | USE_CALLER_MORTALS |
RESULT = NEWMORTALLONG | |
END | USE_CALLER_MORTALS |
RESULT = NEWMORTALLONG | |
VARIABLE | vTime |
long | lTime |
NODE | nItem |
tm | GmTime |
GmTime | tm_year = 1970 |
GmTime | tm_mon = 1 |
GmTime | tm_mday = 1 |
GmTime | tm_hour = 0 |
GmTime | tm_min = 0 |
GmTime | tm_sec = 0 |
GmTime | tm_isdst = -1 |
USE_CALLER_MORTALS | |
nItem = PARAMETERLIST | |
vTime = CONVERT2LONG(EVALUATEEXPRESSION(CAR(nItem))) | |
ASSERTOKE | |
lTime = LONGVALUE(vTime) | |
RESULT = NEWMORTALLONG | |
END VARIABLE | vTime |
long | lTime |
NODE | nItem |
USE_CALLER_MORTALS | |
nItem = PARAMETERLIST | |
vTime = CONVERT2LONG(EVALUATEEXPRESSION(CAR(nItem))) | |
ASSERTOKE | |
lTime = LONGVALUE(vTime) | |
RESULT = NEWMORTALLONG | |
END VARIABLE | vTime |
END VARIABLE | vOffset |
time_t | lTime |
NODE | nItem |
tm * | pGmTime |
tm | GmTime |
nItem = PARAMETERLIST | |
vTime = CONVERT2LONG(EVALUATEEXPRESSION(CAR(nItem))) | |
ASSERTOKE | |
nItem = CDR(nItem) | |
vOffset = CONVERT2LONG(EVALUATEEXPRESSION(CAR(nItem))) | |
ASSERTOKE | |
lTime = LONGVALUE(vTime) | |
pGmTime = mygmtime(&lTime,&GmTime) | |
pGmTime | tm_year = LONGVALUE(vOffset) |
pGmTime | tm_isdst = -1 |
RESULT = NEWMORTALLONG | |
END VARIABLE | vTime |
END VARIABLE | vOffset |
time_t | lTime |
NODE | nItem |
tm * | pGmTime |
tm | GmTime |
nItem = PARAMETERLIST | |
vTime = CONVERT2LONG(EVALUATEEXPRESSION(CAR(nItem))) | |
ASSERTOKE | |
nItem = CDR(nItem) | |
vOffset = CONVERT2LONG(EVALUATEEXPRESSION(CAR(nItem))) | |
ASSERTOKE | |
lTime = LONGVALUE(vTime) | |
pGmTime = mygmtime(&lTime,&GmTime) | |
pGmTime | tm_mon = LONGVALUE(vOffset) |
pGmTime | tm_isdst = -1 |
RESULT = NEWMORTALLONG |
|
|
|
Definition at line 38 of file time.c. Referenced by mygmktime(). |
|
Definition at line 34 of file time.c. Referenced by mygmtime(). |
|
Definition at line 36 of file time.c. Referenced by mygmtime(). |
|
Definition at line 40 of file time.c. Referenced by mygmktime(). |
|
Definition at line 39 of file time.c. Referenced by mygmktime(). |
|
Definition at line 35 of file time.c. Referenced by mygmtime(). |
|
Value: ( ((src1 >= 0L) && (src2 >= 0L) \ && (dest < 0L)) || ((src1 < 0L) && (src2 < 0L) && (dest >= 0L)) ) Definition at line 46 of file time.c. Referenced by mygmktime(). |
|
Definition at line 52 of file time.c. Referenced by mygmktime(). |
|
|
|
Value: COMMAND(XXX)\ NOTIMPLEMENTED;\ END |
|
Value: vTime = CONVERT2LONG(EVALUATEEXPRESSION(CAR(nItem)));\ ASSERTOKE;\ if( vTime )GmTime.x = LONGVALUE(vTime);\ nItem = CDR(nItem);\ if( nItem == 0 )goto NoMoreTime;\ Referenced by if(). |
|
Value: COMMAND(XXX)\ VARIABLE vTime,vOffset;\ long lTime;\ NODE nItem;\ \ nItem = PARAMETERLIST;\ if( nItem == 0 ){\ RESULT = NULL;\ RETURN;\ }\ vTime = CONVERT2LONG(EVALUATEEXPRESSION(CAR(nItem)));\ ASSERTOKE;\ nItem = CDR(nItem);\ vOffset = CONVERT2LONG(EVALUATEEXPRESSION(CAR(nItem)));\ ASSERTOKE;\ if( memory_IsUndef(vTime) || memory_IsUndef(vOffset) ){\ RESULT = NULL;\ RETURN;\ }\ lTime = LONGVALUE(vTime);\ RESULT = NEWMORTALLONG;\ ASSERTNULL(RESULT)\ LONGVALUE(RESULT) = lTime + LONGVALUE(vOffset)*YYY;\ END |
|
Value: COMMAND(NAME)\ \ VARIABLE vTime;\ time_t lTime;\ NODE nItem;\ struct tm *pGmTime,GmTime;\ \ USE_CALLER_MORTALS;\ nItem = PARAMETERLIST;\ if( nItem ){\ vTime = EVALUATEEXPRESSION(CAR(nItem));\ ASSERTOKE;\ }else\ vTime = NULL;\ \ RESULT = NEWMORTALLONG;\ ASSERTNULL(RESULT)\ \ if( memory_IsUndef(vTime) )\ lTime = (long)time(NULL)+ TimeDifference();\ else\ lTime = LONGVALUE(CONVERT2LONG(vTime));\ \ pGmTime = mygmtime(&lTime,&GmTime);\ LONGVALUE(RESULT) = pGmTime->FIELD;\ END |
|
|
|
|
|
|
|
|
|
Definition at line 912 of file time.c. References RETURN. |
|
Definition at line 856 of file time.c. References RETURN. |
|
Definition at line 828 of file time.c. References RETURN. |
|
Definition at line 778 of file time.c. References RETURN, and TAKE_ARGUMENT. |
|
|
|
|
|
|
|
|
|
Definition at line 56 of file time.c. References _BASE_YEAR, _days, _LEAP_YEAR_ADJUST, _MAX_YEAR, ChkAdd, ChkMul, mygmtime(), and NULL. |
|
Definition at line 153 of file time.c. References _DAY_SEC, _FOUR_YEAR_SEC, _YEAR_SEC, and NULL. Referenced by log_printf(), log_thread(), mygmktime(), and TimeDifference(). |
|
Definition at line 241 of file time.c. References lTime, mygmtime(), NULL, and pGmTime. |
|
ADDSECOND =section time =display AddSecond() This function takes two arguments. The first argument is a time value, the second is an integer value. The function increments the seconds by the second argument and returns the time value. This function is the simplest from the arithmetic's point of view, because it simply adds the second argument to the first argument and returns the result. |
|
Definition at line 42 of file time.c. Referenced by mygmktime(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 313 of file time.c. Referenced by build_TableItemBytes(), dupl(), mcsub(), p_b_cclass(), p_b_coll_elem(), printDouble(), printInt(), regcomp(), and regerror(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 763 of file time.c. Referenced by file_time_accessed(), file_time_created(), file_time_modified(), and TimeDifference(). |
|
|
|
Initial value: { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 310 of file time.c. Referenced by TimeDifference(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GMTIME =section time =display GmTime() This function returns the GMT time expressed as seconds since January 1, 1970, 00:00am. The function does not accept any argument. This function is similar to the function R<NOW> but returns the GMT time instead of the actual local time. |
|
NOW =section time =display Now() This function returns the local time expressed as seconds since January 1, 1970, 00:00am. The function does not accept any argument. This function is similar to the function R<GMTIME> but returns the local time instead of the actual GMT. |
|
|
|
|
|
FORMATDATE =section time =display FORMATDATE() =verbatim FormatDate("format",time) =noverbatim Formats a time value (or date) according to the format string. The format string may contain placeholders. The first argument is the format string the second argument is the time value to convert. If the second argument is missing or T<undef> then the local time is converted. =details This function uses the first argument as a formatting string. This string may contain the following character strings: =verbatim YEAR four digit year YY two digit year MON three letter abbreviation of the month name MM month 0M month with leading zero if needed MONTH-NAME* name of the month DD day of the month 0D day of the month with leading zero if needed WD week day on a single digit starting with sunday=0 WEEKDAY-NAME the name of the weekday WDN three letter abbreviation fo the week day name HH hours (24 hours notation) 0H hours with leading zero if needed (24 hours notation) hh hours (12 hours notation) 0h hours with leading zero if needed (12 hours notation) mm minutes 0m minutes with leading zero if needed am pm is am or pm =noverbatim Any other character in the format string will get into the result verbatim. |
|
|
|
|
|
|
|
|
|
|
|
ADDMONTH =section time =display AddMonth() This function takes two arguments. The first argument is a time value, the second is an integer value. The function increments the month by the second argument and returns the time value for the same day, hour and minute but some months later or sooner in case the second argument is negative. If the resulting value is on a day that does not exist on the result month then the day part of the result is decreased. For example: =verbatim print FormatTime("MONTH DAY, YEAR",AddMonth(TimeValue(2000,03,31),1)) =noverbatim will print =verbatim April 30, 2000 =noverbatim |
|
|
|
ADDYEAR =section time =display AddYear() This function takes two arguments. The first argument is a time value, the second is an integer value. The function increments the year of the time value by the second argument and returns the time value for the same month, day, hour and minute but some years later or sooner in case the second argument is negative. This is a bit more complex than just adding 365*24*60*60 to the value, because leap-years are longer and in case you add several years to the time value you should consider adding these longer years extra days. This is calculated correct in this function. If the original time value is February 29 on a leap-year and the resulting value is in a year, which is not leap year the function will return February 28. Note that because of this correction using the function in a loop is not the same as using it once. For example: =verbatim print AddYear(TimeValue(2000,02,29),4),"\n" print AddYear(AddYear(TimeValue(2000,02,29),2),2),"\n" =noverbatim will print two different values. |
|
|
|
LOCATLTOGMTIME =section time =display LocalToGmTime() This function accepts one argument that has to be the number of seconds elapsed since January 1, 1970 0:00 am in local time. The function returns the same number of seconds in GMT. In other words the function converts a local time value to GMT time value. |
|
|
|
TIMEVALUE =section time =display TimeValue() This function gets zero or more, at most six arguments and interprets them as year, month, day, hour, minute and seconds and calculates the number of seconds elapsed since January 1, 1970 till the time specified. If some arguments are missing or T<undef> the default values are the following: =itemize =item year = 1970 =item month = January =item day = 1st =item hours = 0 =item minutes = 0 =item seconds = 0 =noitemize |
|
|
|
|
|
Initial value: { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } |