}
else {
tt = icaltime_as_timet(t);
- webcit_fmt_date(buf, tt, 0);
+ webcit_fmt_date(buf, tt, DATEFMT_FULL);
StrBufAppendPrintf(Target, "<dt>");
StrBufAppendPrintf(Target, _("Starting date/time:"));
StrBufAppendPrintf(Target, "</dt><dd>%s</dd>", buf);
if (p != NULL) {
t = icalproperty_get_dtend(p);
tt = icaltime_as_timet(t);
- webcit_fmt_date(buf, tt, 0);
+ webcit_fmt_date(buf, tt, DATEFMT_FULL);
StrBufAppendPrintf(Target, "<dt>");
StrBufAppendPrintf(Target, _("Ending date/time:"));
StrBufAppendPrintf(Target, "</dt><dd>%s</dd>", buf);
else
IcalTime = icaltime_current_time_with_zone(get_default_icaltimezone());
display_icaltimetype_as_webform(&IcalTime, "dtstart", 0);
+
+ wprintf("<INPUT TYPE=\"CHECKBOX\" NAME=\"dtstart_time\" ID=\"dtstart_time\" VALUE=\"yes\"");
+ if (!IcalTime.is_date) {
+ wprintf("CHECKED=\"CHECKED\"");
+ }
+ wprintf(">");
+ wprintf(_("Time associated"));
wprintf("</TD></TR>\n");
wprintf("<TR><TD>");
else
IcalTime = icaltime_current_time_with_zone(get_default_icaltimezone());
display_icaltimetype_as_webform(&IcalTime, "due", 0);
-
+
+ wprintf("<INPUT TYPE=\"CHECKBOX\" NAME=\"due_time\" ID=\"due_time\" VALUE=\"yes\"");
+ if (!IcalTime.is_date) {
+ wprintf("CHECKED=\"CHECKED\"");
+ }
+ wprintf(">");
+ wprintf(_("Time associated"));
wprintf("</TD></TR>\n");
todoStatus = icalcomponent_get_status(vtodo);
wprintf("<TR><TD>\n");
icalproperty_free(prop);
}
if (IsEmptyStr(bstr("nodtstart"))) {
- icaltime_from_webform(&t, "dtstart");
+ if (yesbstr("dtstart_time")) {
+ icaltime_from_webform(&t, "dtstart");
+ }
+ else {
+ icaltime_from_webform_dateonly(&t, "dtstart");
+ }
icalcomponent_add_property(vtodo,
icalproperty_new_dtstart(t)
);
icalproperty_free(prop);
}
if (IsEmptyStr(bstr("nodue"))) {
- icaltime_from_webform(&t, "due");
+ if (yesbstr("due_time")) {
+ icaltime_from_webform(&t, "due");
+ }
+ else {
+ icaltime_from_webform_dateonly(&t, "due");
+ }
icalcomponent_add_property(vtodo,
icalproperty_new_due(t)
);
}
wprintf(_("Hour: "));
- wprintf("<SELECT NAME=\"%s_hour\" SIZE=\"1\">\n", prefix);
+ wprintf("<SELECT NAME=\"%s_hour\" ID=\"%s_hour\" SIZE=\"1\">\n", prefix, prefix);
for (i=0; i<=23; ++i) {
if (time_format == WC_TIMEFORMAT_24) {
wprintf("</SELECT>\n");
wprintf(_("Minute: "));
- wprintf("<SELECT NAME=\"%s_minute\" SIZE=\"1\">\n", prefix);
+ wprintf("<SELECT NAME=\"%s_minute\" ID=\"%s_minute\" SIZE=\"1\">\n", prefix, prefix);
for (i=0; i<=59; ++i) {
if ( (i % 5 == 0) || (tm.tm_min == i) ) {
wprintf("<OPTION %s VALUE=\"%d\">:%02d</OPTION>\n",
}
else {
tt = icaltime_as_timet(t);
- webcit_fmt_date(buf, tt, 1);
+ webcit_fmt_date(buf, tt, DATEFMT_BRIEF);
wprintf("<i>%s</i> %s<br>",
_("Starting date/time:"), buf);
if (q != NULL) {
t = icalproperty_get_dtend(q);
tt = icaltime_as_timet(t);
- webcit_fmt_date(buf, tt, 1);
+ webcit_fmt_date(buf, tt, DATEFMT_BRIEF);
wprintf("<i>%s</i> %s<br>", _("Ending date/time:"), buf);
}
escputs((char *)icalproperty_get_comment(q));
wprintf("<br />");
}
- webcit_fmt_date(buf, event_tt, 1);
+ webcit_fmt_date(buf, event_tt, DATEFMT_BRIEF);
wprintf("<i>%s</i> %s<br>", _("Starting date/time:"), buf);
- webcit_fmt_date(buf, event_tte, 1);
+ webcit_fmt_date(buf, event_tte, DATEFMT_BRIEF);
wprintf("<i>%s</i> %s<br>", _("Ending date/time:"), buf);
q = icalcomponent_get_first_property(Cal->cal,ICAL_DESCRIPTION_PROPERTY);
if (q) {
escputs((char *)icalproperty_get_comment(q));
wprintf("<br />");
}
- webcit_fmt_date(buf, event_tt, 1);
+ webcit_fmt_date(buf, event_tt, DATEFMT_BRIEF);
wprintf("<i>%s</i> %s<br>", _("Starting date/time:"), buf);
- webcit_fmt_date(buf, event_tte, 1);
+ webcit_fmt_date(buf, event_tte, DATEFMT_BRIEF);
wprintf("<i>%s</i> %s<br>", _("Ending date/time:"), buf);
q = icalcomponent_get_first_property(Cal->cal,ICAL_DESCRIPTION_PROPERTY);
if (q) {
/*
* Helper function for do_tasks_view(). Returns the due date/time of a vtodo.
*/
-time_t get_task_due_date(icalcomponent *vtodo) {
+time_t get_task_due_date(icalcomponent *vtodo, int *is_date) {
icalproperty *p;
if (vtodo == NULL) {
return get_task_due_date(
icalcomponent_get_first_component(
vtodo, ICAL_VTODO_COMPONENT
- )
+ ), is_date
);
}
p = icalcomponent_get_first_property(vtodo, ICAL_DUE_PROPERTY);
if (p != NULL) {
- return(icaltime_as_timet(icalproperty_get_due(p)));
+ struct icaltimetype t = icalproperty_get_due(p);
+
+ if (is_date)
+ *is_date = t.is_date;
+ return(icaltime_as_timet(t));
}
else {
return(0L);
time_t t1;
time_t t2;
- t1 = get_task_due_date(Task1->cal);
- t2 = get_task_due_date(Task2->cal);
+ t1 = get_task_due_date(Task1->cal, NULL);
+ t2 = get_task_due_date(Task2->cal, NULL);
if (t1 < t2) return(-1);
if (t1 > t2) return(1);
return(0);
Pos = GetNewHashPos(WCC->disp_cal_items, 0);
while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
icalproperty_status todoStatus;
+ int is_date;
Cal = (disp_cal*)vCal;
wprintf("<tr><td>");
wprintf("</a>\n");
wprintf("</td>\n");
- due = get_task_due_date(Cal->cal);
+ due = get_task_due_date(Cal->cal, &is_date);
wprintf("<td><span");
if (due > 0) {
- webcit_fmt_date(buf, due, 0);
+ webcit_fmt_date(buf, due, is_date ? DATEFMT_RAWDATE : DATEFMT_FULL);
wprintf(">%s",buf);
}
else {
/*
* Format a date/time stamp for output
*/
-void webcit_fmt_date(char *buf, time_t thetime, int brief)
+void webcit_fmt_date(char *buf, time_t thetime, int Format)
{
struct tm tm;
struct tm today_tm;
localtime_r(&thetime, &tm);
- if (brief) {
+ /*
+ * DATEFMT_FULL: full display
+ * DATEFMT_BRIEF: if date == today, show only the time
+ * otherwise, for messages up to 6 months old,
+ * show the month and day, and the time
+ * older than 6 months, show only the date
+ * DATEFMT_RAWDATE: show full date, regardless of age
+ */
- /* If date == today, show only the time */
- if ((tm.tm_year == today_tm.tm_year)
- &&(tm.tm_mon == today_tm.tm_mon)
- &&(tm.tm_mday == today_tm.tm_mday)) {
- if (time_format == WC_TIMEFORMAT_24)
- wc_strftime(buf, 32, "%k:%M", &tm);
- else
- wc_strftime(buf, 32, "%l:%M%p", &tm);
- }
- /* Otherwise, for messages up to 6 months old, show the month and day, and the time */
- else if (today_timet - thetime < 15552000) {
- if (time_format == WC_TIMEFORMAT_24)
- wc_strftime(buf, 32, "%b %d %k:%M", &tm);
+ switch (Format) {
+ case DATEFMT_BRIEF:
+ if ((tm.tm_year == today_tm.tm_year)
+ &&(tm.tm_mon == today_tm.tm_mon)
+ &&(tm.tm_mday == today_tm.tm_mday)) {
+ if (time_format == WC_TIMEFORMAT_24)
+ wc_strftime(buf, 32, "%k:%M", &tm);
+ else
+ wc_strftime(buf, 32, "%l:%M%p", &tm);
+ }
+ else if (today_timet - thetime < 15552000) {
+ if (time_format == WC_TIMEFORMAT_24)
+ wc_strftime(buf, 32, "%b %d %k:%M", &tm);
+ else
+ wc_strftime(buf, 32, "%b %d %l:%M%p", &tm);
+ }
+ else {
+ wc_strftime(buf, 32, "%b %d %Y", &tm);
+ }
+ break;
+ case DATEFMT_FULL:
+ if (time_format == WC_TIMEFORMAT_24)
+ wc_strftime(buf, 32, "%a %b %d %Y %T %Z", &tm);
else
- wc_strftime(buf, 32, "%b %d %l:%M%p", &tm);
- }
- /* older than 6 months, show only the date */
- else {
- wc_strftime(buf, 32, "%b %d %Y", &tm);
- }
- }
- else {
- if (time_format == WC_TIMEFORMAT_24)
- wc_strftime(buf, 32, "%a %b %d %Y %T %Z", &tm);
- else
- wc_strftime(buf, 32, "%a %b %d %Y %r %Z", &tm);
+ wc_strftime(buf, 32, "%a %b %d %Y %r %Z", &tm);
+ break;
+ case DATEFMT_RAWDATE:
+ wc_strftime(buf, 32, "%a %b %d %Y", &tm);
+ break;
}
}
{
char datebuf[64];
message_summary *Msg = (message_summary*) CTX;
- webcit_fmt_date(datebuf, Msg->date, 1);
+ webcit_fmt_date(datebuf, Msg->date, DATEFMT_BRIEF);
StrBufAppendBufPlain(Target, datebuf, -1, 0);
}
{
char datebuf[64];
message_summary *Msg = (message_summary*) CTX;
- webcit_fmt_date(datebuf, Msg->date, 0);
+ webcit_fmt_date(datebuf, Msg->date, DATEFMT_FULL);
StrBufAppendBufPlain(Target, datebuf, -1, 0);
}
void tmplput_MAIL_SUMM_DATE_NO(StrBuf *Target, WCTemplputParams *TP)
// TODO: Collapse into one function
function toggleTaskDtStart(event) {
var checkBox = $('nodtstart');
+ var checkBoxTime = $('dtstart_time');
dtStart = document.getElementById("dtstart");
+ dtStartHour = document.getElementById("dtstart_hour");
+ dtStartMinute = document.getElementById("dtstart_minute");
if (checkBox.checked) {
dtStart.disabled = true;
+ dtStartHour.disabled = true;
+ dtStartMinute.disabled = true;
dtStart.style.textDecoration = "line-through";
} else {
dtStart.disabled = false;
+ if (checkBoxTime.checked) {
+ dtStartHour.disabled = false;
+ dtStartMinute.disabled = false;
+ } else {
+ dtStartHour.disabled = true;
+ dtStartMinute.disabled = true;
+ }
dtStart.style.textDecoration = "";
if (dtStart.value.length == 0)
dtStart.dpck._initCurrentDate();
}
function toggleTaskDue(event) {
var checkBox = $('nodue');
+ var checkBoxTime = $('due_time');
dueField = document.getElementById("due");
+ dueFieldHour = document.getElementById("due_hour");
+ dueFieldMinute = document.getElementById("due_minute");
if (checkBox.checked) {
dueField.disabled = true;
+ dueFieldHour.disabled = true;
+ dueFieldMinute.disabled = true;
dueField.style.textDecoration = "line-through";
} else {
dueField.disabled = false;
+ if (checkBoxTime.checked) {
+ dueFieldHour.disabled = false;
+ dueFieldMinute.disabled = false;
+ } else {
+ dueFieldHour.disabled = true;
+ dueFieldMinute.disabled = true;
+ }
dueField.style.textDecoration = "";
if (dueField.value.length == 0)
dueField.dpck._initCurrentDate();
toggleTaskDtStart(null);
toggleTaskDue(null);
$('nodtstart').observe('click', toggleTaskDtStart);
+ $('dtstart_time').observe('click', toggleTaskDtStart);
$('nodue').observe('click', toggleTaskDue);
+ $('due_time').observe('click', toggleTaskDue);
}
}
function TaskViewGatherCategoriesFromTable() {
int get_time_format_cached (void);
int xtoi(const char *in, size_t len);
const char *get_selected_language(void);
-void webcit_fmt_date(char *buf, time_t thetime, int brief);
+
+#define DATEFMT_FULL 0
+#define DATEFMT_BRIEF 1
+#define DATEFMT_RAWDATE 2
+void webcit_fmt_date(char *buf, time_t thetime, int Format);
int fetch_http(char *url, char *target_buf, int maxbytes);
void free_attachments(wcsession *sess);
void summary(void);