mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-08 17:13:56 +00:00
Implemented datetime format
SVN revision: 1304
This commit is contained in:
parent
46960a5ce6
commit
70c6592061
@ -1074,22 +1074,24 @@ Default is <i>"0, attribname, attribvalue, 80, 500"</i>. Trailing parameters can
|
||||
so specifying for example only the flags is possible.
|
||||
<p>
|
||||
|
||||
<LI><b><code>Type <attribute> = date | numeric | userlist</b></code>
|
||||
<LI><b><code>Type <attribute> = date | datetime | numeric | userlist</b></code>
|
||||
<br>
|
||||
A normal attribute can contain strings of any type. With this option, attributes can be
|
||||
forced to be numeric or to be a date, or to consist of a list of all users from the password file.
|
||||
When new logbook entries are made,
|
||||
numeric attributes are checked to contain only digits. Note that JavaScript has to be
|
||||
enabled to do this.<br><br>
|
||||
forced to be numeric or to be a date/time, or to consist of a list of all users from
|
||||
the password file. When new logbook entries are made, numeric attributes are checked
|
||||
to contain only digits. Note that JavaScript has to be enabled to do this.<br><br>
|
||||
|
||||
Attributes of type <b><code>date</code></b> are treated as a date.
|
||||
Attributes of type <b><code>date</code></b> are treated as a date. Their format for
|
||||
display can be controlled by the <b><code>Date format</code></b> option.
|
||||
Upon entry, drop-down boxes are displayed which let the user select the day, month and
|
||||
year. Alternatively, a pop-up date picker using a calendar can be displayed if JavaScript
|
||||
is enabled. Date attributes are saved internally as seconds since 1.1.1970, and can therefore
|
||||
be sorted propoerly by clicking on the header of a logbook entry list. On the find page,
|
||||
dates can be searched for via a start and end date. If date attributes are used in a quick filter
|
||||
(see above), a drop-down quick filter box is displayed which lets the user select "last day",
|
||||
"last week", "next week", and so on.<p>
|
||||
"last week", "next week", and so on. The <b><code>datetime</code></b> type combines
|
||||
a date and time in HH:MM. The output of this combination is controlled by the
|
||||
<b><code>Time format</code></b> option.<br><br>
|
||||
|
||||
If the attribute type is <b><code>userlist</code></b>, a drop-down box is displayed which contains
|
||||
all user names from the current password file. This can be useful for example in a bug
|
||||
|
||||
43
src/elogd.c
43
src/elogd.c
@ -6,6 +6,9 @@
|
||||
Contents: Web server program for Electronic Logbook ELOG
|
||||
|
||||
$Log$
|
||||
Revision 1.611 2005/03/30 08:59:35 ritt
|
||||
Implemented datetime format
|
||||
|
||||
Revision 1.610 2005/03/29 21:20:37 ritt
|
||||
Fixed find form for DATETIME
|
||||
|
||||
@ -1270,6 +1273,8 @@ struct {
|
||||
".XML", "text/xml"}, {
|
||||
".XSL", "text/xml"}, {
|
||||
".ZIP", "application/x-zip-compressed"}, {
|
||||
|
||||
".THUMB", "image/jpeg"}, { // hard-coded for now...
|
||||
"", ""},};
|
||||
|
||||
typedef struct {
|
||||
@ -7156,7 +7161,7 @@ void send_file_direct(char *file_name)
|
||||
str[i] = 0;
|
||||
|
||||
for (i = 0; filetype[i].ext[0]; i++)
|
||||
if (strstr(str, filetype[i].ext))
|
||||
if (chkext(str, filetype[i].ext))
|
||||
break;
|
||||
|
||||
if (!getcfg("global", "charset", charset, sizeof(charset)))
|
||||
@ -14918,14 +14923,16 @@ void show_select_navigation(LOGBOOK * lbs)
|
||||
|
||||
time_t retrieve_date(char *index, BOOL bstart)
|
||||
{
|
||||
int year, month, day, current_year, current_month, current_day;
|
||||
char pm[10], py[10], pd[10], str[NAME_LENGTH];
|
||||
int year, month, day, hour, minute, current_year, current_month, current_day;
|
||||
char pm[10], py[10], pd[10], ph[10], pn[10], str[NAME_LENGTH];
|
||||
struct tm tms;
|
||||
time_t ltime;
|
||||
|
||||
sprintf(pm, "m%s", index);
|
||||
sprintf(py, "y%s", index);
|
||||
sprintf(pd, "d%s", index);
|
||||
sprintf(ph, "h%s", index);
|
||||
sprintf(pn, "n%s", index);
|
||||
|
||||
time(<ime);
|
||||
memcpy(&tms, localtime(<ime), sizeof(tms));
|
||||
@ -14977,18 +14984,32 @@ time_t retrieve_date(char *index, BOOL bstart)
|
||||
|
||||
}
|
||||
|
||||
/* if hour not given, use 0 */
|
||||
if (*getparam(ph)) {
|
||||
hour = atoi(getparam(ph));
|
||||
} else
|
||||
hour = 0;
|
||||
|
||||
/* if minute not given, use 0 */
|
||||
if (*getparam(pn)) {
|
||||
minute = atoi(getparam(pn));
|
||||
} else
|
||||
minute = 0;
|
||||
|
||||
memset(&tms, 0, sizeof(struct tm));
|
||||
tms.tm_year = year - 1900;
|
||||
tms.tm_mon = month - 1;
|
||||
tms.tm_mday = day;
|
||||
tms.tm_hour = 0;
|
||||
tms.tm_hour = hour;
|
||||
tms.tm_min = minute;
|
||||
tms.tm_isdst = -1;
|
||||
|
||||
if (tms.tm_year < 90)
|
||||
tms.tm_year += 100;
|
||||
|
||||
ltime = mktime(&tms);
|
||||
|
||||
if (!bstart)
|
||||
if (!bstart && *getparam(ph) == 0)
|
||||
/* end time is first second of next day */
|
||||
ltime += 3600 * 24;
|
||||
|
||||
@ -16096,7 +16117,7 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
|
||||
disp_filter = TRUE;
|
||||
|
||||
for (i = 0; i < lbs->n_attr; i++) {
|
||||
if (attr_flags[i] & AF_DATE) {
|
||||
if (attr_flags[i] & (AF_DATE | AF_DATETIME)) {
|
||||
sprintf(str, "%da", i);
|
||||
ltime = retrieve_date(str, TRUE);
|
||||
if (ltime > 0)
|
||||
@ -16168,7 +16189,10 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
|
||||
rsprintf("<td class=\"attribvalue\">");
|
||||
if (ltime1) {
|
||||
memcpy(&tms, localtime(<ime1), sizeof(struct tm));
|
||||
strcpy(format, "%x");
|
||||
if (attr_flags[i] & AF_DATE)
|
||||
strcpy(format, DEFAULT_DATE_FORMAT);
|
||||
else
|
||||
strcpy(format, DEFAULT_TIME_FORMAT);
|
||||
strftime(str, sizeof(str), format, &tms);
|
||||
if (ltime2 > 0)
|
||||
rsprintf("%s %s", loc("From"), str);
|
||||
@ -16177,7 +16201,10 @@ void show_elog_list(LOGBOOK * lbs, INT past_n, INT last_n, INT page_n, char *inf
|
||||
}
|
||||
if (ltime2) {
|
||||
memcpy(&tms, localtime(<ime2), sizeof(struct tm));
|
||||
strcpy(format, "%x");
|
||||
if (attr_flags[i] & AF_DATE)
|
||||
strcpy(format, DEFAULT_DATE_FORMAT);
|
||||
else
|
||||
strcpy(format, DEFAULT_TIME_FORMAT);
|
||||
strftime(str, sizeof(str), format, &tms);
|
||||
if (ltime1 > 0)
|
||||
rsprintf(" %s %s", loc("to"), str);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user