Пример #1
0
int OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec)
	{
	int offset_hms, offset_day;
	long time_jd;
	int time_year, time_month, time_day;
	/* split offset into days and day seconds */
	offset_day = offset_sec / SECS_PER_DAY;
	/* Avoid sign issues with % operator */
	offset_hms  = offset_sec - (offset_day * SECS_PER_DAY);
	offset_day += off_day;
	/* Add current time seconds to offset */
	offset_hms += tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec;
	/* Adjust day seconds if overflow */
	if (offset_hms >= SECS_PER_DAY)
		{
		offset_day++;
		offset_hms -= SECS_PER_DAY;
		}
	else if (offset_hms < 0)
		{
		offset_day--;
		offset_hms += SECS_PER_DAY;
		}

	/* Convert date of time structure into a Julian day number.
	 */

	time_year = tm->tm_year + 1900;
	time_month = tm->tm_mon + 1;
	time_day = tm->tm_mday;

	time_jd = date_to_julian(time_year, time_month, time_day);

	/* Work out Julian day of new date */
	time_jd += offset_day;

	if (time_jd < 0)
		return 0;

	/* Convert Julian day back to date */

	julian_to_date(time_jd, &time_year, &time_month, &time_day);

	if (time_year < 1900 || time_year > 9999)
		return 0;

	/* Update tm structure */

	tm->tm_year = time_year - 1900;
	tm->tm_mon = time_month - 1;
	tm->tm_mday = time_day;

	tm->tm_hour = offset_hms / 3600;
	tm->tm_min = (offset_hms / 60) % 60;
	tm->tm_sec = offset_hms % 60;

	return 1;
		
}
Пример #2
0
void
day_selected_cb (GuiCalendar *t_calendar, gpointer user_data) {

guint day, month, year;
gchar *temp;
   
    gui_calendar_get_date (t_calendar, &year, &month, &day);
    gtk_widget_destroy(td_calendar_window);
    
    tasks_due_julian_day = date_to_julian (day, month, year);
    temp = julian_to_str (tasks_due_julian_day, config.date_format);
    gtk_entry_set_text (GTK_ENTRY(due_date_entry), temp);
}
Пример #3
0
/* Convert tm structure and offset into julian day and seconds */
static int julian_adj(const struct tm *tm, int off_day, long offset_sec,
		long *pday, int *psec)
	{
	int offset_hms, offset_day;
	long time_jd;
	int time_year, time_month, time_day;
	/* split offset into days and day seconds */
	offset_day = offset_sec / SECS_PER_DAY;
	/* Avoid sign issues with % operator */
	offset_hms  = offset_sec - (offset_day * SECS_PER_DAY);
	offset_day += off_day;
	/* Add current time seconds to offset */
	offset_hms += tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec;
	/* Adjust day seconds if overflow */
	if (offset_hms >= SECS_PER_DAY)
		{
		offset_day++;
		offset_hms -= SECS_PER_DAY;
		}
	else if (offset_hms < 0)
		{
		offset_day--;
		offset_hms += SECS_PER_DAY;
		}

	/* Convert date of time structure into a Julian day number.
	 */

	time_year = tm->tm_year + 1900;
	time_month = tm->tm_mon + 1;
	time_day = tm->tm_mday;

	time_jd = date_to_julian(time_year, time_month, time_day);

	/* Work out Julian day of new date */
	time_jd += offset_day;

	if (time_jd < 0)
		return 0;

	*pday = time_jd;
	*psec = offset_hms;
	return 1;
	}
Пример #4
0
void
ical_events_list_create(gint calendar, GUI *appGUI) {

struct ics_file *entry;
struct ics_entry *item;
gint j;
GtkTreeIter iter;
GSList *node;
guint32 julian;
gboolean year_flag;

    gtk_list_store_clear (GTK_LIST_STORE(appGUI->cal->ical_events_list_store));

    j = 0;

    while (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(appGUI->opt->calendar_ical_files_store), &iter, NULL, j++)) {
        gtk_tree_model_get(GTK_TREE_MODEL(appGUI->opt->calendar_ical_files_store), &iter, 
                           ICAL_COLUMN_USE_YEAR, &year_flag, -1);
        if (j-1 == calendar) break;
    }

    entry = g_slist_nth_data (appGUI->cal->ics_files_list, calendar);

    if (entry->entries_list != NULL) {
    
        for (j = 0, node = entry->entries_list; node != NULL; node = node->next, j++) {
            item = g_slist_nth_data (entry->entries_list, j);

            if (year_flag == TRUE) {
                julian = date_to_julian(item->date.day, item->date.month-1, item->date.year);
            } else {
                julian = date_to_julian(item->date.day, item->date.month-1, get_current_year());
            }

            gtk_list_store_append(appGUI->cal->ical_events_list_store, &iter);

            if (year_flag == TRUE) {
                gtk_list_store_set(appGUI->cal->ical_events_list_store, &iter, 
                                   I_COLUMN_DATE, julian_to_str (julian, config.date_format),
                                   I_COLUMN_DATE_JULIAN, julian,
                                   I_COLUMN_SUMMARY, str_remove_backslash (item->summary), -1); 
            } else {
                gtk_list_store_set(appGUI->cal->ical_events_list_store, &iter, 
                                   I_COLUMN_DATE, julian_to_str (julian, DATE_NAME_DAY),
                                   I_COLUMN_DATE_JULIAN, julian,
                                   I_COLUMN_SUMMARY, str_remove_backslash (item->summary), -1); 
            }

            if (get_current_day() == item->date.day && get_current_month()+1 == item->date.month && year_flag == FALSE) {
                gtk_list_store_set(appGUI->cal->ical_events_list_store, &iter, 
                                   I_COLUMN_FONT_WEIGHT, PANGO_WEIGHT_BOLD, -1);
            } else if (get_current_day() == item->date.day && get_current_month()+1 == item->date.month && get_current_year() == item->date.year) {
                gtk_list_store_set(appGUI->cal->ical_events_list_store, &iter, 
                                   I_COLUMN_FONT_WEIGHT, PANGO_WEIGHT_BOLD, -1);
            } else {
                gtk_list_store_set(appGUI->cal->ical_events_list_store, &iter, 
                                   I_COLUMN_FONT_WEIGHT, PANGO_WEIGHT_NORMAL, -1);
            }
        }
    }

}