extern void format_abbrev_appt(Dtcm_appointment *appt, char *b, Boolean show_am, DisplayType display) { int hr, mn; Tick tick; Lines *lines=NULL; Boolean am = True; struct tm *tm; _Xltimeparams localtime_buf; if(appt==NULL || b==NULL) return; _csa_iso8601_to_tick(appt->time->value->item.string_value, &tick); tm = _XLocaltime(&tick, localtime_buf); hr = tm->tm_hour; mn = tm->tm_min; if (showtime_set(appt) && !magic_time(tick)) { if (display == HOUR12) { am = adjust_hour(&hr); if (show_am) sprintf(b, "%2d:%02d%s ", hr, mn, am ? "a" : "p"); else sprintf(b, "%2d:%02d ", hr, mn); } else sprintf(b, "%02d%02d ", hr, mn); } lines = text_to_lines(appt->what->value->item.string_value, 1); if (lines != NULL && lines->s != NULL) { (void) cm_strcat(b, lines->s); destroy_lines(lines); } }
/* * Format the appointment in the character array passed (assumed to be pointing * to allocated space) to contain the time followed by the what string. The * appointment string is truncated at "max" chars or at DEFAULT_APPT_LEN if * max is 0. */ extern void format_appt(Dtcm_appointment *appt, char *b, DisplayType display, int max) { int hr, mn, len, i = 0, j = 0; Tick tick; struct tm *tm; register char *what_ptr; _Xltimeparams localtime_buf; if (!appt || !b) return; _csa_iso8601_to_tick(appt->time->value->item.string_value, &tick); tm = _XLocaltime(&tick, localtime_buf); hr = tm->tm_hour; mn = tm->tm_min; if (showtime_set(appt) && !magic_time(tick)) { if (display == HOUR12) { adjust_hour(&hr); sprintf(b, "%2d:%02d ", hr, mn); } else sprintf(b, "%02d%02d ", hr, mn); i = cm_strlen(b); } if (appt->what->value->item.string_value) { if (max <= 0) max = DEFAULT_APPT_LEN; len = max - i; what_ptr = appt->what->value->item.string_value; while ((i < len) && *what_ptr != '\n' && *what_ptr) b[i++] = *what_ptr++; b[i] = '\0'; } }
static int day_xytoclock(Calendar *c, int x, int y, Tick t) { int daybegin, hr, val; char buf[10]; struct tm tm; Props *p; _Xltimeparams localtime_buf; p = (Props *)c->properties; daybegin = get_int_prop(p, CP_DAYBEGIN); tm = *_XLocaltime(&t, localtime_buf); hr = (x == 1) ? (12 + y) : (y + daybegin - 1); /* * If y == 0 then the user is clicking on the no-time area. There * is no hour associated with no-time events. */ if (y == 0) hr = 0; (void)sprintf(buf, "%d/%d/%d", tm.tm_mon+1, tm.tm_mday, tm.tm_year+1900); val =cm_getdate(buf, NULL); val = val+(hr*(int)hrsec); adjust_dst(t, val); return(val); }
extern void format_week_header(Tick date, OrderingType order, char *buf) { Calendar *c = calendar; struct tm *tm; _Xltimeparams localtime_buf; tm = _XLocaltime(&date, localtime_buf); /* NL_COMMENT Attention Translator: This string is used in the calendar week view. In the C locale it has the form: Monday, January 16, 1995 strftime conversion string: "%A, %B %e, %Y" is used. The string will be used in a label that looks like this: Week Starting Monday, January 16, 1995 Use the appropriate strftime conversion for your locale. */ strftime(buf, 80, catgets(c->DT_catd, 1, 993, "Week Starting %A, %B %e, %Y"), tm); }
int main (int argc, char *argv[]) { struct or_dbrec dbrec; char renamebuf[256]; time_t now; struct tm *time_ptr; _Xltimeparams localtime_buf; aa_argv0 = argv[0]; setlocale (LC_ALL, ""); dtsearch_catd = catopen (FNAME_DTSRCAT, 0); austools_catd = catopen (FNAME_AUSCAT, 0); time (&now); time_ptr = _XLocaltime(&now, localtime_buf); strftime (renamebuf, sizeof (renamebuf), catgets (dtsearch_catd, MS_misc, 22, "%A, %b %d %Y, %I:%M %p"), time_ptr); printf (catgets (dtsearch_catd, MS_misc, 23, "%s: Version %s. Run %s.\n"), aa_argv0, DtSrVERSION, renamebuf); if (argc < 2) { printf (catgets (dtsearch_catd, MS_dbrec, 310, "USAGE: %s <dbname>\n"), aa_argv0); return 2; } sprintf (renamebuf, "%s.d00", argv[1]); db_oflag = O_RDONLY; /* db files may be read-only */ d_open (argv[1], "o"); if (db_status != S_OKAY) { printf (catgets (dtsearch_catd, MS_dbrec, 330, "Could not open '%s' database.\n%s\n"), argv[1], vista_msg(PROGNAME"293")); return 3; } d_recfrst (OR_DBREC, 0); if (db_status != S_OKAY) { printf (catgets (dtsearch_catd, MS_dbrec, 340, "No dbrec record in database '%s'.\n"), argv[1]); return 4; } d_recread (&dbrec, 0); if (db_status != S_OKAY) { printf (catgets (dtsearch_catd, MS_dbrec, 350, "Can't read dbrec record in database '%s'.\n%s\n"), argv[1], vista_msg(PROGNAME"306")); return 5; } swab_dbrec (&dbrec, NTOH); print_dbrec (argv[1], &dbrec); return 0; } /* main() */
/* * Format the appointment in the character array passed (assumed to be pointing * to allocated space) to contain the formatted string for the group * appointment editor. The string is truncated at "max" chars or at * DEFAULT_GAPPT_LEN if max is 0. */ extern void format_gappt(Dtcm_appointment *appt, char *name, char *b, DisplayType display, int max) { int hr, mn, i, j; Tick tick; char *what_ptr; struct tm *tm; _Xltimeparams localtime_buf; if (!appt || !b) return; _csa_iso8601_to_tick(appt->time->value->item.string_value, &tick); if ((tick > 0) && !magic_time(tick) && showtime_set(appt)) { tm = _XLocaltime(&tick, localtime_buf); hr = tm->tm_hour; mn = tm->tm_min; if (display == HOUR12) { adjust_hour(&hr); sprintf(b, "%2d:%02d ", hr, mn); } else sprintf(b, "%02d%02d ", hr, mn); } else sprintf(b, "%6s", " "); if (max <= 0) max = DEFAULT_GAPPT_LEN; i = cm_strlen(b); j = 0; while (j < 10 && i < max && name && name[j]) b[i++] = name[j++]; while (j < 11 && i < max) b[i++] = ' ', ++j; if (i >= max) { b[i - 1] = '\0'; return; } b[i] = '\0'; if (appt->what->value->item.string_value) { what_ptr = appt->what->value->item.string_value; while (i < max && *what_ptr != '\n' && *what_ptr) b[i++] = *what_ptr++; b[i] = '\0'; } }
static boolean_t magic_time(time_t t) { boolean_t magic = B_FALSE; struct tm *tm; _Xltimeparams localtime_buf; tm = _XLocaltime(&t, localtime_buf); if (tm->tm_hour == 3 && tm->tm_min == 41) magic = B_TRUE; return(magic); }
extern void paint_day_header(Calendar *c, Tick date, void *rect) { Props *p = (Props*)c->properties; OrderingType ot = get_int_prop(p, CP_DATEORDERING); int pfy, x; char buf[100]; Boolean inrange = False; Colormap cmap; Pixel foreground_pixel; XFontSetExtents fontextents; struct tm *tm; _Xltimeparams localtime_buf; tm = _XLocaltime(&date, localtime_buf); CalFontExtents(c->fonts->labelfont, &fontextents); pfy = fontextents.max_logical_extent.height; XtVaGetValues(c->canvas, XmNcolormap, &cmap, NULL); XtVaGetValues(c->canvas, XmNforeground, &foreground_pixel, NULL); buf [0] = '\0'; /* NL_COMMENT Attention Translator: This string is used in the calendar day view. In the C locale it has the form: Monday, January 16, 1995 strftime conversion string: "%A, %B %e, %Y" is used. Use the appropriate strftime conversion for your locale. */ strftime(buf, 100, catgets(c->DT_catd, 1, 992, "%A, %B %e, %Y"), tm); inrange = today_inrange(c, date); x = gr_center(c->view->winw-(int)MOBOX_AREA_WIDTH, buf, c->fonts->labelfont) + (int)MOBOX_AREA_WIDTH; if (c->xcontext->screen_depth >= 8 && inrange) gr_text_rgb(c->xcontext, x, c->view->topoffset - (pfy/2), c->fonts->labelfont, buf, foreground_pixel, cmap, rect); else gr_text(c->xcontext, x, c->view->topoffset - (pfy/2), c->fonts->labelfont, buf, rect); }
extern void monthbox_datetoxy(Calendar *c) { char str[5]; int week, x_off, dayw, daym, mo; Day *day_info = (Day *) c->view->day_info; XFontSetExtents fontextents; int pfy; int col_w = day_info->col_w; int row_h = day_info->row_h; struct tm tm; _Xltimeparams localtime_buf; CalFontExtents(c->fonts->labelfont, &fontextents); pfy = fontextents.max_logical_extent.height; tm = *_XLocaltime(&c->view->date, localtime_buf); mo = tm.tm_mon+1; dayw = tm.tm_wday; daym = tm.tm_mday; week = (12+tm.tm_mday-tm.tm_wday)/7; day_info->day_selected_x = c->view->outside_margin + INSIDE_MARGIN + col_w*dayw; if (mo == month(day_info->month1)) day_info->day_selected_y = day_info->month1_y + row_h*week; else if (mo == month(day_info->month2)) day_info->day_selected_y = day_info->month2_y + row_h*week; else if (mo == month(day_info->month3)) day_info->day_selected_y = day_info->month3_y + row_h*week; sprintf(str, "%d", daym); x_off = gr_center(col_w, str, c->fonts->labelfont); day_info->day_selected_x2 = day_info->day_selected_x+x_off; day_info->day_selected_y2 = day_info->day_selected_y + pfy; day_info->day_selected = daym; }
/* * Convert tick to m/d */ extern void format_date3(Tick t, OrderingType order, SeparatorType sep, char *buf) { int m, d; struct tm *tm; char *str = (char *) separator_str(sep); _Xltimeparams localtime_buf; buf[0]=NULL; tm = _XLocaltime(&t, localtime_buf); m = tm->tm_mon+1; d = tm->tm_mday; switch(order) { case ORDER_YMD: case ORDER_MDY: default: (void) sprintf(buf, "%d%s%.2d", m, str, d); break; case ORDER_DMY: (void) sprintf(buf, "%.2d%s%d", d, str, m); break; } }
/* * Convert tick to m, d, y string. e.g. May 1, 1988 */ extern void format_date(Tick t, OrderingType order, char *buf, int day_and_date, int and_date, int full_day) { int m, d, y, wd; struct tm *tm; _Xltimeparams localtime_buf; buf[0]=NULL; tm = _XLocaltime(&t, localtime_buf); m = tm->tm_mon+1; d = tm->tm_mday; y = tm->tm_year + 1900; wd = tm->tm_wday; switch(order) { case ORDER_DMY: /* STRING_EXTRACTION SUNW_DESKSET_CM_MSG : * * %s, %d %s %4d is a form of the date format. * Change this to reflect your local convention. * eg. In the German locale, "%s, %d %s %4d" may be changed * to "%s. %d %s %4d". */ if (day_and_date) if (full_day) (void)sprintf(buf, "%s, %d %s %4d", days2[wd], d, months[m], y); else (void)sprintf(buf, "%s, %d %s %4d", days[wd], d, months[m], y); else if (and_date) (void)sprintf(buf, "%d %s %4d", d, months[m], y); else (void) sprintf(buf, "%s %4d", months[m], y); break; case ORDER_YMD: if (day_and_date) if (full_day) (void)sprintf(buf, "%s, %4d %s %d", days2[wd], y, months[m], d); else (void)sprintf(buf, "%s, %4d %s %d", days[wd], y, months[m], d); else if (and_date) (void)sprintf(buf, "%4d %s %d", y, months[m], d); else (void) sprintf(buf, "%4d %s", y, months[m]); break; case ORDER_MDY: default: if (day_and_date) if (full_day) (void)sprintf(buf, "%s, %s %d %4d", days2[wd], months[m], d, y); else (void)sprintf(buf, "%s, %s %d %4d", days[wd], months[m], d, y); else if (and_date) (void)sprintf(buf, "%s %d %4d", months[m], d, y); else (void) sprintf(buf, "%s %4d", months[m], y); break; } }
/* * Format 2 lines of appt data */ extern void format_line2(Dtcm_appointment *appt, char *buf1, char *buf2, DisplayType display) { Tick tick, end_tick = 0; int hour1, min1, hour2, min2; Lines *lines; char *s1, *s2; struct tm *tm; _Xltimeparams localtime_buf; _csa_iso8601_to_tick(appt->time->value->item.string_value, &tick); if (appt->end_time) _csa_iso8601_to_tick(appt->end_time->value->item.string_value, &end_tick); /* * Extract an appointment and format it into 2 lines of no more * then maxchars */ *buf1 = *buf2 = NULL; if (appt == NULL || appt->what->value->item.string_value == NULL) return; tm = _XLocaltime(&tick, localtime_buf); hour1 = tm->tm_hour; min1 = tm->tm_min; if (!showtime_set(appt) || magic_time(tick)) { lines = (Lines *) text_to_lines(appt->what->value->item.string_value, 1); if (lines==NULL) return; strncpy(buf2, lines->s, 256); destroy_lines(lines); return; } s1 = s2 = "am"; if (display == HOUR12 && !adjust_hour(&hour1)) s1="pm"; if (end_tick) { hour2 = hour(end_tick); min2 = minute(end_tick); if (display == HOUR12 && !adjust_hour(&hour2)) s2="pm"; } if (end_tick == 0 || (hour1 == hour2 && min1 == min2 && (strcmp(s1, s2) == 0))) { if (display == HOUR24) sprintf(buf1, "%02d%.2d", hour1, min1); else sprintf(buf1, "%d:%.2d%s", hour1, min1, s1); } else { if (display == HOUR12) sprintf(buf1, "%d:%.2d%s-%d:%.2d%s", hour1, min1, s1, hour2, min2, s2); else sprintf(buf1, "%02d%02d-%02d%02d", hour1, min1, hour2, min2); } lines = (Lines *) text_to_lines(appt->what->value->item.string_value, 1); if (lines == NULL || lines->s == NULL || (cm_strlen(lines->s) == 1 && lines->s[0] == ' ')) buf2[0] = NULL; else sprintf(buf2, " %s", lines->s); destroy_lines(lines); }
/* * Format 2 lines of appt data */ extern void format_maxchars(Dtcm_appointment *appt, char *buf1, int maxchars, DisplayType display) { Tick tick, end_tick = 0; int hour1, min1, hour2, min2; Lines *lines; char *s1, *s2; struct tm *tm; _Xltimeparams localtime_buf; _csa_iso8601_to_tick(appt->time->value->item.string_value, &tick); if (appt->end_time) _csa_iso8601_to_tick(appt->end_time->value->item.string_value, &end_tick); *buf1 = NULL; if (appt == NULL || appt->what->value->item.string_value == NULL) return; tm = _XLocaltime(&tick, localtime_buf); hour1 = tm->tm_hour; min1 = tm->tm_min; if (showtime_set(appt) && !magic_time(tick)) { s1 = s2 = "am"; if (display == HOUR12 && !adjust_hour(&hour1)) s1="pm"; if (end_tick) { hour2 = hour(end_tick); if (display == HOUR12 && !adjust_hour(&hour2)) s2="pm"; min2 = minute(end_tick); } if (end_tick == 0 || hour1 == hour2 && min1 == min2) { if (display == HOUR24) sprintf(buf1, "%02d%02d ", hour1, min1); else sprintf(buf1, "%d:%.2d%s ", hour1, min1, s1); } else { if (display == HOUR12) sprintf(buf1, "%d:%.2d%s-%d:%.2d%s ", hour1, min1, s1, hour2, min2, s2); else sprintf(buf1, "%02d%02d-%02d%02d ", hour1, min1, hour2, min2); } } lines = (Lines *) text_to_lines(appt->what->value->item.string_value, 10); while (lines != NULL) { if ((cm_strlen(buf1) + cm_strlen(lines->s)) < (maxchars-2)) { cm_strcat(buf1, lines->s); lines = lines->next; if (lines != NULL) cm_strcat(buf1, " - "); } else { strncat(buf1, lines->s, (maxchars - cm_strlen(buf1)-1)); break; } } destroy_lines(lines); }
/* * Format 1 line of appt data. Returns True if begin hour is < 10 - thus * padding needs to be done. */ extern Boolean format_line(Tick tick, char *what, char *buf, int end_tick, Boolean showtime, DisplayType display) { int hr, hr1, mn, mn1; Boolean am=True; Boolean am_end=True; struct tm *tm; Boolean pad = FALSE; _Xltimeparams localtime_buf; if (buf==NULL) return pad; buf[0]=NULL; tm = _XLocaltime(&tick, localtime_buf); hr = tm->tm_hour; mn = tm->tm_min; if (showtime && !magic_time(tick)) { if (display == HOUR12) am = adjust_hour(&hr); if (end_tick && end_tick != tick) { hr1 = hour(end_tick); mn1 = minute(end_tick); if (display == HOUR12) { am_end = adjust_hour(&hr1); if (am_end != am) { (void) sprintf(buf, "%d:%.2d - %d:%.2d%s ", hr, mn, hr1, mn1, am_end ? "am" : "pm"); } else { (void) sprintf(buf, "%d:%.2d - %d:%.2d ", hr, mn, hr1, mn1); } if (hr < 10) pad = TRUE; } else (void) sprintf(buf, "%02d%02d - %02d%02d ", hr, mn, hr1, mn1); } else { /* Check to see if there are 2 digits in in initial time format. If so, pad with 1 space; if not 2. The font is not fixed width, so I have to line it up myself.. */ if (display == HOUR12) { if (hr > 9) (char *)sprintf(buf, "%2d:%.2d%s ", hr, mn, am ? "a" : "p"); else { (char *)sprintf(buf, "%d:%.2d%s ", hr, mn, am ? "a" : "p"); pad = TRUE; } } else (char *)sprintf(buf, "%02d%02d ", hr, mn); } } if (what) (void) cm_strcat(buf, what); return pad; }
/* * Format 2 lines of appt data */ static void format_entry(Paint_cache *cache_entry, char *buf1, char *buf2, DisplayType display) { Tick tick, end_tick = 0; int hour1, min1, hour2, min2; Lines *lines; char *s1, *s2; struct tm *tm; _Xltimeparams localtime_buf; tick = cache_entry->start_time; end_tick = cache_entry->end_time; /* * Extract an appointment and format it into 2 lines of no more * then maxchars */ *buf1 = *buf2 = '\0'; if (cache_entry == NULL || cache_entry->summary == NULL) return; tm = _XLocaltime(&tick, localtime_buf); hour1 = tm->tm_hour; min1 = tm->tm_min; if (!cache_entry->show_time || magic_time(tick)) { lines = (Lines *) text_to_lines(cache_entry->summary, 1); if (lines==NULL) return; strncpy(buf2, lines->s, 256); destroy_lines(lines); return; } s1 = s2 = "am"; if (display == HOUR12 && !adjust_hour(&hour1)) s1="pm"; if (end_tick) { hour2 = hour(end_tick); min2 = minute(end_tick); if (display == HOUR12 && !adjust_hour(&hour2)) s2="pm"; } if (end_tick == 0 || (hour1 == hour2 && min1 == min2 && (strcmp(s1, s2) == 0))) { if (display == HOUR24) sprintf(buf1, "%02d%.2d", hour1, min1); else sprintf(buf1, "%d:%.2d%s", hour1, min1, s1); } else { if (display == HOUR12) sprintf(buf1, "%d:%.2d%s-%d:%.2d%s", hour1, min1, s1, hour2, min2, s2); else sprintf(buf1, "%02d%02d-%02d%02d", hour1, min1, hour2, min2); } lines = (Lines *) text_to_lines(cache_entry->summary, 1); if (lines == NULL || lines->s == NULL || (cm_strlen(lines->s) == 1 && lines->s[0] == ' ')) buf2[0] = '\0'; else sprintf(buf2, " %s", lines->s); destroy_lines(lines); }