relative date/time values.
utc_offset = 0; /* Timezone offset from UTC */
ipp_uchar_t date[11]; /* dateTime value */
- if (sscanf(value, "%d-%d-%dT%d:%d:%d%d", &year, &month, &day, &hour, &minute, &second, &utc_offset) < 6)
+ if (*value == 'P')
{
+ /*
+ * Time period...
+ */
+
+ time_t curtime; /* Current time in seconds */
+ int period = 0, /* Current period value */
+ saw_T = 0; /* Saw time separator */
+
+ curtime = time(NULL);
+
+ for (valueptr = value + 1; *valueptr; valueptr ++)
+ {
+ if (isdigit(*valueptr & 255))
+ {
+ period = strtol(valueptr, &valueptr, 10);
+
+ if (!valueptr || period < 0)
+ {
+ report_error(f, v, user_data, "Bad dateTime value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename);
+ return (0);
+ }
+ }
+
+ if (*valueptr == 'Y')
+ {
+ curtime += 365 * 86400 * period;
+ period = 0;
+ }
+ else if (*valueptr == 'M')
+ {
+ if (saw_T)
+ curtime += 60 * period;
+ else
+ curtime += 30 * 86400 * period;
+
+ period = 0;
+ }
+ else if (*valueptr == 'D')
+ {
+ curtime += 86400 * period;
+ period = 0;
+ }
+ else if (*valueptr == 'H')
+ {
+ curtime += 3600 * period;
+ period = 0;
+ }
+ else if (*valueptr == 'S')
+ {
+ curtime += period;
+ period = 0;
+ }
+ else if (*valueptr == 'T')
+ {
+ saw_T = 1;
+ period = 0;
+ }
+ else
+ {
+ report_error(f, v, user_data, "Bad dateTime value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename);
+ return (0);
+ }
+ }
+
+ return (ippSetDate(ipp, attr, element, ippTimeToDate(curtime)));
+ }
+ else if (sscanf(value, "%d-%d-%dT%d:%d:%d%d", &year, &month, &day, &hour, &minute, &second, &utc_offset) < 6)
+ {
+ /*
+ * Date/time value did not parse...
+ */
+
report_error(f, v, user_data, "Bad dateTime value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename);
return (0);
}
<dd style="margin-left: 5.0em">Inserts a single "$" character.
<dt><b>$ENV[</b><i>name</i><b>]</b>
<dd style="margin-left: 5.0em">Inserts the value of the named environment variable, or an empty string if the environment variable is not defined.
+<dt><b>$date-current</b>
+<dd style="margin-left: 5.0em">Inserts the current date and time using the ISO-8601 format ("yyyy-mm-ddThh:mm:ssZ").
+<dt><b>$date-start</b>
+<dd style="margin-left: 5.0em">Inserts the starting date and time using the ISO-8601 format ("yyyy-mm-ddThh:mm:ssZ").
<dt><b>$filename</b>
<dd style="margin-left: 5.0em">Inserts the filename provided to
<b>ipptool</b>(8)
.\" Licensed under Apache License v2.0. See the file "LICENSE" for more
.\" information.
.\"
-.TH ipptoolfile 5 "CUPS" "26 April 2019" "Apple Inc."
+.TH ipptoolfile 5 "CUPS" "13 May 2019" "Apple Inc."
.SH NAME
ipptoolfile \- ipptool file format
.SH DESCRIPTION
\fB$ENV[\fIname\fB]\fR
Inserts the value of the named environment variable, or an empty string if the environment variable is not defined.
.TP 5
+\fB$date-current\fR
+Inserts the current date and time using the ISO-8601 format ("yyyy-mm-ddThh:mm:ssZ").
+.TP 5
+\fB$date-start\fR
+Inserts the starting date and time using the ISO-8601 format ("yyyy-mm-ddThh:mm:ssZ").
+.TP 5
\fB$filename\fR
Inserts the filename provided to
.BR ipptool (8)
_ippVarsInit(&vars, NULL, (_ipp_ferror_cb_t)error_cb, (_ipp_ftoken_cb_t)token_cb);
+ _ippVarsSet(&vars, "date-start", iso_date(ippTimeToDate(time(NULL))));
+
/*
* We need at least:
*
data->transfer = data->def_transfer;
data->version = data->def_version;
+ _ippVarsSet(vars, "date-current", iso_date(ippTimeToDate(time(NULL))));
+
f->attrs = ippNew();
f->group_tag = IPP_TAG_ZERO;
}
if (_ippFileReadToken(f, name, sizeof(name)) && _ippFileReadToken(f, temp, sizeof(temp)))
{
+ _ippVarsSet(vars, "date-current", iso_date(ippTimeToDate(time(NULL))));
_ippVarsExpand(vars, value, temp, sizeof(value));
_ippVarsSet(vars, name, value);
}
{
if (!_ippVarsGet(vars, name))
{
+ _ippVarsSet(vars, "date-current", iso_date(ippTimeToDate(time(NULL))));
_ippVarsExpand(vars, value, temp, sizeof(value));
_ippVarsSet(vars, name, value);
}
if (_ippFileReadToken(f, temp, sizeof(temp)))
{
+ _ippVarsSet(vars, "date-current", iso_date(ippTimeToDate(time(NULL))));
_ippVarsExpand(vars, data->file_id, temp, sizeof(data->file_id));
}
else