1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
/*************************************************************************
*
* HTCd - Copyright (C) 1998-2006 Henrik Rydberg
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <sh/htc.h>
#include <mt/dates.h>
#include <limits.h>
const int ENDTIME=INT_MAX-4*SEC_PER_DAY;
TOK_IMPL(endtime) { out<<ENDTIME; }
TOK_IMPL(now) { out<<Now(); }
TOK_IMPL(minutes) { out<<(60*atoi(env[0])); }
TOK_IMPL(days) { out<<Days(atoi(env[0])); }
TOK_IMPL(today) { out<<Today(atoi(env[0])); }
TOK_IMPL(sunday) { out<<Sunday(atoi(env[0])); }
TOK_IMPL(week) { out<<Week(env.req->lang,atoi(env[0])); }
TOK_IMPL(month) { out<<Month(env.req->lang,atoi(env[0])); }
TOK_IMPL(sweek) { out<<SWeek(env.req->lang,atoi(env[0])); }
TOK_IMPL(smonth) { out<<SMonth(env.req->lang,atoi(env[0])); }
////////////////////////////////////////////////////////////
TOK_IMPL(time2http) { out<<httpTime(atoi(env[0])); }
TOK_IMPL(time2htc) { out<<htcTime(env.req->lang,atoi(env[0])); }
TOK_IMPL(htc2time) { out<<htcTime(env.req->lang,env[0]); }
TOK_IMPL(cvttime) { out<<cvtTime(env[0]); }
////////////////////////////////////////////////////////////
void envAddDates(tokmap& T)
{
TOK_ADD(endtime,"",tok_t::PUBLIC,
"%Endtime\n"
"%Syntax: \\endtime\n"
"%\n"
"%Last time (safely) representable by internal format\n"
);
TOK_ADD(now,"",tok_t::PUBLIC,
"%Now\n"
"%Syntax: \\now\n"
"%\n"
"%Current system time. Note that this may be out of\n"
"%sync with filesystem.\n"
);
TOK_ADD(minutes,"x",tok_t::PUBLIC,
"%Minutes in seconds\n"
"%Syntax: \\minutes{m}\n"
);
TOK_ADD(days,"x",tok_t::PUBLIC,
"%Days in seconds\n"
"%Syntax: \\days{d}\n"
);
TOK_ADD(today,"x",tok_t::PUBLIC,
"%Beginning of day\n"
"%Syntax: \\today{t}\n"
"%\n"
"%Get beginning of day.\n"
);
TOK_ADD(sunday,"x",tok_t::PUBLIC,
"%Last sunday\n"
"%Syntax: \\sunday{t}\n"
"%\n"
"%Get beginning of last sunday.\n"
);
TOK_ADD(week,"x",tok_t::PUBLIC,
"%Weekday (long)\n"
"%Syntax: \\week{t}\n"
"%\n"
"%Get long weekday format.\n"
"%Output in current language.\n"
);
TOK_ADD(month,"x",tok_t::PUBLIC,
"%Month (long)\n"
"%Syntax: \\month{t}\n"
"%\n"
"%Get long month format.\n"
"%Output in current language.\n"
);
TOK_ADD(sweek,"x",tok_t::PUBLIC,
"%Weekday (short)\n"
"%Syntax: \\sweek{t}\n"
"%\n"
"%Get short weekday format.\n"
"%Output in current language.\n"
);
TOK_ADD(smonth,"x",tok_t::PUBLIC,
"%Month (short)\n"
"%Syntax: \\smonth{t}\n"
"%\n"
"%Get short month format.\n"
"%Output in current language.\n"
);
//////////////////////////////////////////////////////
TOK_ADD(time2http,"x",tok_t::PUBLIC,
"%HTTP Standard Time (GMT)\n"
"%Syntax: \\time2http{t}\n"
"%\n"
"%Outputs time in standard HTTP format.\n"
);
TOK_ADD(time2htc,"x",tok_t::PUBLIC,
"%HTC Standard Time (Local)\n"
"%Syntax: \\time2htc{t}\n"
"%\n"
"%Outputs time in standard HTC format, which is local time.\n"
"%Output in current language.\n"
);
TOK_ADD(htc2time,"x",tok_t::PUBLIC,
"%Convert to time from HTC (Local)\n"
"%Syntax: \\htc2time{timestring}\n"
"%\n"
"%Converts text to local time internal format.\n"
);
TOK_ADD(cvttime,"x",tok_t::PUBLIC,
"%Convert user input time (Local)\n"
"%Syntax: \\cvttime{timestring}\n"
"%\n"
"%Tries to make an intelligent conversion of user input\n"
"%under the assumption that a local time is given.\n"
);
}
|