示例#1
0
/**
 * pk_update_detail_obj_new_from_data:
 *
 * Creates a new #PkUpdateDetailObj object with values.
 *
 * Return value: a new #PkUpdateDetailObj object
 **/
PkUpdateDetailObj *
pk_update_detail_obj_new_from_data (const PkPackageId *id, const gchar *updates, const gchar *obsoletes,
				    const gchar *vendor_url, const gchar *bugzilla_url, const gchar *cve_url,
				    PkRestartEnum restart, const gchar *update_text,
				    const gchar *changelog, PkUpdateStateEnum state, GDate *issued, GDate *updated)
{
	PkUpdateDetailObj *obj = NULL;

	/* create new object */
	obj = pk_update_detail_obj_new ();
	obj->id = pk_package_id_copy (id);
	obj->updates = g_strdup (updates);
	obj->obsoletes = g_strdup (obsoletes);
	obj->vendor_url = g_strdup (vendor_url);
	obj->bugzilla_url = g_strdup (bugzilla_url);
	obj->cve_url = g_strdup (cve_url);
	obj->restart = restart;
	obj->update_text = g_strdup (update_text);
	obj->changelog = g_strdup (changelog);
	obj->state = state;
	if (issued != NULL)
		obj->issued = g_date_new_dmy (issued->day, issued->month, issued->year);
	if (updated != NULL)
		obj->updated = g_date_new_dmy (updated->day, updated->month, updated->year);

	return obj;
}
示例#2
0
gint orage_days_between(struct tm *t1, struct tm *t2)
{
    GDate *g_t1, *g_t2;
    gint dd;
    g_t1 = g_date_new_dmy(t1->tm_mday, t1->tm_mon, t1->tm_year);
    g_t2 = g_date_new_dmy(t2->tm_mday, t2->tm_mon, t2->tm_year);
    dd = g_date_days_between(g_t1, g_t2);
    g_date_free(g_t1);
    g_date_free(g_t2);
    return(dd);
}
示例#3
0
static void
gnc_period_select_set_date_common (GncPeriodSelect *period, const GDate *date)
{
    GncPeriodSelectPrivate *priv;

    priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
    if (date)
    {
        if (priv->date_base)
            g_date_free(priv->date_base);
        priv->date_base = g_date_new_dmy(g_date_get_day(date),
                                         g_date_get_month(date),
                                         g_date_get_year(date));
        if (priv->date_label == NULL)
        {
            priv->date_align = gtk_alignment_new(0.5, 0.5, 0, 0);
            gtk_alignment_set_padding(GTK_ALIGNMENT(priv->date_align), 0, 0, 6, 0);
            gtk_box_pack_start(GTK_BOX(period), priv->date_align, TRUE, TRUE, 0);
            priv->date_label = gtk_label_new("");
            gtk_container_add(GTK_CONTAINER(priv->date_align), priv->date_label);
            gtk_widget_show_all(priv->date_align);
        }
        gnc_period_sample_update_date_label(period);
        return;
    }

    if (priv->date_base)
    {
        g_date_free(priv->date_base);
        priv->date_base = NULL;
        gtk_widget_destroy(priv->date_align);
        priv->date_align = NULL;
        priv->date_label = NULL;
    }
}
示例#4
0
文件: utils.c 项目: rosedu/osmo
guint
utl_get_weekend_days_in_month_my (guint month, guint year)
{
	GDate *tmpdate = NULL;
	guint i, day, days, weekend_days;

	g_return_val_if_fail (g_date_valid_dmy (1, month, year) == TRUE, 0);

	tmpdate = g_date_new_dmy (1, month, year);
	g_return_val_if_fail (tmpdate != NULL, 0);

	days = utl_date_get_days_in_month (tmpdate);
	weekend_days = 0;

	for (i = 1; i <= days; i++) {
		g_date_set_day (tmpdate, i);
		day = g_date_get_weekday (tmpdate);
		if (day == G_DATE_SATURDAY || day == G_DATE_SUNDAY) {
			weekend_days++;
		}
	}

	g_date_free (tmpdate);
	return weekend_days;
}
示例#5
0
static GDate *
get_release_date(MbRelease release)
{
    char buf[256];
    int num_releases = mb_release_get_num_release_events(release);
    MbReleaseEvent evt;
    GDate *rv = NULL;

    if (num_releases <= 0) return NULL;

    evt = mb_release_get_release_event(release, 0);

    mb_release_event_get_date(evt, buf, sizeof(buf));
    {
        int matched, year=1, month=1, day=1;
        matched = sscanf(buf, "%u-%u-%u", &year, &month, &day);
        if (matched >= 1) {
            rv = g_date_new_dmy(
                day == 0 ? 1 : day,
                month == 0 ? 1 : month,
                year
            );
        }
    }
    return rv;
}
示例#6
0
gboolean
handle_element_date_or_datetime (gchar* name, Date_or_datetime** store, xmlNodePtr node)
{
	gchar *value = NULL;

	if (g_strcmp0 ((gchar *) node->name, name) != 0)
		return FALSE;

	/* store is expected NULL. If not, maybe the element
	 * unexpectedly occurs multiple times => warn and reassign
	 */
	if (*store != NULL)
		log_warn("multiple assignment of string variable");
	else
		*store = g_new0(Date_or_datetime, 1);

	value = xml_get_node_text(node);

	g_debug ("**** handle_element_date_or_datetime() node: %s - value: '%s'", node->name, value);

	if (strlen (value) < 12) {
		gint day = 0, month = 0, year = 0;

		/* Populate only date */
		gchar** date_tokens = g_strsplit (value, "-", -1);
		if (*date_tokens == NULL) {
			*store = NULL;
			return TRUE;
		}

		year = strtol(date_tokens[0], NULL, 10);
		month = strtol(date_tokens[1], NULL, 10);
		day = strtol(date_tokens[2], NULL, 10);

		(*store)->date = g_date_new_dmy ((GDateDay)day, (GDateMonth)month, (GDateYear)year);
		(*store)->date_time = NULL;

		g_strfreev(date_tokens);

	} else {
		struct tm t;
		time_t tt;

		/* convert string to 'struct tm' */
		if (value[10] == 'T') /* remove 'T' in iso timestamp if neccessary */
			value[10] = ' ';

		strptime(value, "%Y-%m-%d %H:%M:%S", &t); /* string to tm */

		tt = time_gm(&t); /* tm to seconds */

		g_debug ("**** handle_element_date_or_datetime() tt: '%lu'", tt);

		(*store)->date_time = g_new0(time_t, 1);
		*((*store)->date_time) = tt;
		(*store)->date = NULL;
	}

	return TRUE;
}
static void
log_window_calendar_chats_day_selected_cb (GtkWidget       *calendar,
					   EmpathyLogWindow *window)
{
	guint  year;
	guint  month;
	guint  day;
	GDate *date;

	gtk_calendar_get_date (GTK_CALENDAR (calendar), &year, &month, &day);
	if (day == 0)
		/* No date selected */
		return;

	/* We need this hear because it appears that the months start from 0 */
	month++;

	date = g_date_new_dmy (day, month, year);

	DEBUG ("Currently selected date is: %04u-%02u-%02u", year, month, day);

	log_window_chats_get_messages (window, date);

	g_date_free (date);
}
示例#8
0
GST_END_TEST
GST_START_TEST (test_date_tags)
{
  GstTagList *tag_list, *tag_list2;
  GDate *date, *date2;
  gchar *str;

  date = g_date_new_dmy (14, 10, 2005);
  tag_list = gst_tag_list_new_empty ();
  gst_tag_list_add (tag_list, GST_TAG_MERGE_APPEND, GST_TAG_DATE, date, NULL);

  str = gst_tag_list_to_string (tag_list);
  fail_if (str == NULL);
  fail_if (strstr (str, "2005-10-14") == NULL);

  tag_list2 = gst_tag_list_new_from_string (str);
  fail_if (tag_list2 == NULL);
  fail_if (!gst_tag_list_get_date (tag_list2, GST_TAG_DATE, &date2));
  fail_unless (gst_tag_list_is_equal (tag_list2, tag_list));
  gst_tag_list_unref (tag_list2);
  g_free (str);

  fail_if (g_date_compare (date, date2) != 0);
  fail_if (g_date_get_day (date) != 14);
  fail_if (g_date_get_month (date) != 10);
  fail_if (g_date_get_year (date) != 2005);
  fail_if (g_date_get_day (date2) != 14);
  fail_if (g_date_get_month (date2) != 10);
  fail_if (g_date_get_year (date2) != 2005);
  g_date_free (date2);

  gst_tag_list_unref (tag_list);
  g_date_free (date);
}
示例#9
0
gboolean
handle_element_date (gchar* name, GDate** store, xmlNodePtr node)
{
	GDate* date = NULL;
	gchar* value = NULL;
	gchar** date_tokens = NULL;
	gint day = 0, month = 0, year = 0;

	if (g_strcmp0 ((gchar *) node->name, name) != 0)
		return FALSE;

	value = xml_get_node_text(node);
	date_tokens = g_strsplit (value, "-", -1);

	year = strtol(date_tokens[0], NULL, 10);
	month = strtol(date_tokens[1], NULL, 10);
	day = strtol(date_tokens[2], NULL, 10);

	g_strfreev(date_tokens);

	date = g_date_new_dmy ((GDateDay)day, (GDateMonth)month, (GDateYear)year);

	*store = date;

	return TRUE;
}
示例#10
0
/**
 * itl_HijriGreg:
 *
 * @DateIn: (in): Date struct to convert
 * @Hijri: (in): DateIn date type; TRUE=Hijri, FALSE=Gregorian
 * @UmmAlQura: (in): TRUE=Use Umm Al-Qura algorithm, FALSE=otherwise
 *
 * Convert Hijri date to Gregorian date using Umm Ul-Qura algorithm
 *
 * Return value: (transfer full): Converted Date struct
 */
GDate *itl_HijriGreg (GDate *DateIn, gboolean Hijri, gboolean UmmAlQura) {
  sDate ITLDate;
  GDate *cdate;
  int ret;

  if(Hijri) {
    if(UmmAlQura) {
      ret = H2G(&ITLDate, (int) g_date_get_day(DateIn), (int) g_date_get_month(DateIn), (int)
                g_date_get_year(DateIn));
    }
    else {
      ret = h_date(&ITLDate, (int) g_date_get_day(DateIn), (int) g_date_get_month(DateIn), (int)
                   g_date_get_year(DateIn));
    }
  }
  else {
    if(UmmAlQura) {
      ret = G2H(&ITLDate, (int) g_date_get_day(DateIn), (int) g_date_get_month(DateIn), (int)
                g_date_get_year(DateIn));
    }
    else {
      ret = g_date(&ITLDate, (int) g_date_get_day(DateIn), (int) g_date_get_month(DateIn), (int)
                   g_date_get_year(DateIn));
    }
  }

  cdate = g_date_new_dmy(ITLDate.day, ITLDate.month, ITLDate.year);

  return(cdate);
}
示例#11
0
/** Update the user visible sample date label if it exists on this
 *  widget.  This label is for user feedback only.
 *
 *  @param period The GncPeriodSelect object to update.
 */
static void
gnc_period_sample_update_date_label (GncPeriodSelect *period)
{
    GncPeriodSelectPrivate *priv;
    gchar time_string[MAX_DATE_LENGTH];
    GDate *date;
    GncAccountingPeriod which;

    g_return_if_fail(GNC_IS_PERIOD_SELECT(period));
    priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
    if (!priv->date_label)
        return;
    which = gtk_combo_box_get_active (GTK_COMBO_BOX (priv->selector));
    if (which == -1)
        date = g_date_new_dmy (31, 7, 2013);

    else if (priv->start)
        date = gnc_accounting_period_start_gdate (which, priv->fy_end,
                                                  priv->date_base);
    else
        date = gnc_accounting_period_end_gdate (which, priv->fy_end,
                                                priv->date_base);
    qof_print_gdate (time_string, MAX_DATE_LENGTH, date);
    gtk_label_set_label (GTK_LABEL(priv->date_label), time_string);
    g_date_free (date);
}
示例#12
0
文件: darxencli.c 项目: darxen/Darxen
static gboolean
parse_date(const gchar *option_name, const gchar *value, gpointer data, GError **error)
{
	int month;
	int day;
	int year;
	int hour;
	int minute;
	if (sscanf(value, "%i/%i/%i-%i:%i", &month, &day, &year, &hour, &minute) != 5)
	{
		g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED, "Failed to parse date/time object");
		return FALSE;
	}

	GDate* date = g_date_new_dmy(day, month, year);
	int time = hour * 60 * 60 + minute * 60;

	if (!g_ascii_strcasecmp(option_name, "-a") || !g_ascii_strcasecmp(option_name, "--startdate"))
	{
		dateStart = date;
		timeStart = time;
	}
	else
	{
		dateEnd = date;
		timeEnd = time;
	}

	return TRUE;
}
示例#13
0
static void
read_one_tag (GstTagList * list, const gchar * tag, XmpTag * xmptag,
    const gchar * v, GSList ** pending_tags)
{
  GType tag_type;

  if (xmptag && xmptag->deserialize) {
    xmptag->deserialize (list, tag, xmptag->tag_name, v, pending_tags);
    return;
  }

  tag_type = gst_tag_get_type (tag);

  /* add gstreamer tag depending on type */
  switch (tag_type) {
    case G_TYPE_STRING:{
      gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, tag, v, NULL);
      break;
    }
    default:
      if (tag_type == GST_TYPE_DATE) {
        GDate *date;
        gint d, m, y;

        /* this is ISO 8601 Date and Time Format
         * %F     Equivalent to %Y-%m-%d (the ISO 8601 date format). (C99)
         * %T     The time in 24-hour notation (%H:%M:%S). (SU)
         * e.g. 2009-05-30T18:26:14+03:00 */

        /* FIXME: this would be the proper way, but needs
           #define _XOPEN_SOURCE before #include <time.h>

           date = g_date_new ();
           struct tm tm={0,};
           strptime (dts, "%FT%TZ", &tm);
           g_date_set_time_t (date, mktime(&tm));
         */
        /* FIXME: this cannot parse the date
           date = g_date_new ();
           g_date_set_parse (date, v);
           if (g_date_valid (date)) {
           gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, tag,
           date, NULL);
           } else {
           GST_WARNING ("unparsable date: '%s'", v);
           }
         */
        /* poor mans straw */
        sscanf (v, "%04d-%02d-%02dT", &y, &m, &d);
        date = g_date_new_dmy (d, m, y);
        gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, tag, date, NULL);
        g_date_free (date);
      } else {
        GST_WARNING ("unhandled type for %s from xmp", tag);
      }
      break;
  }
}
示例#14
0
GDate* gnc_g_date_new_today ()
{
    GncDate gncd;
    auto ymd = gncd.year_month_day();
    auto month = static_cast<GDateMonth>(ymd.month);
    auto result = g_date_new_dmy (ymd.day, month, ymd.year);
    g_assert(g_date_valid (result));
    return result;
}void
示例#15
0
/**
 * itl_H2G:
 *
 * @dh: (in): Hijri day
 * @mh: (in): Hijri month
 * @yh: (in): Hijri year
 * 
 * Convert Hijri date to Gregorian date using Umm Ul-Qura algorithm
 *
 * Return value: (transfer full): Gregorian date
 */
GDate *itl_H2G(gint yh, gint mh, gint dh) {
  sDate ITLDate;
  GDate *cdate;
  int ret;

  ret = H2G(&ITLDate, (int) yh, (int) mh, (int) dh);

  cdate = g_date_new_dmy(ITLDate.day, ITLDate.month, ITLDate.year);

  return(cdate);
}
示例#16
0
/**
 * itl_G2H:
 *
 * @dg: (in): Gregorian day
 * @mg: (in): Gregorian month
 * @yg: (in): Gregorian year
 * 
 * Convert Gregorian date to Hijra date using Umm Ul-Qura algorithm
 *
 * Return value: (transfer full): Hijri date
 */
GDate *itl_G2H(gint yg, gint mg, gint dg) {
  sDate ITLDate;
  GDate *cdate;
  int ret;

  ret = G2H(&ITLDate, (int) yg, (int) mg, (int) dg);

  cdate = g_date_new_dmy(ITLDate.day, ITLDate.month, ITLDate.year);

  return(cdate);
}
示例#17
0
/**
 * itl_g_date:
 *
 * @day: (in): Hijri day
 * @month: (in): Hijri month
 * @year: (in): Hijri year
 * 
 * Convert Hijri date to Gregorian date
 *
 * Return value: (transfer full): Gregorian date
 */
GDate *itl_g_date(gint day, gint month, gint year) {
  sDate ITLDate;
  GDate *cdate;
  int ret;

  ret = g_date(&ITLDate, (int) day, (int) month, (int) year);

  cdate = g_date_new_dmy(ITLDate.day, ITLDate.month, ITLDate.year);

  return(cdate);
}
gchar *
get_readable_date (const gchar * format_string,
                   const time_t file_time_raw)
{
	struct tm * file_time;
	gchar * format;
	GDate * today;
	GDate * file_date;
	guint32 file_date_age;
	gchar * readable_date;

	file_time = localtime (&file_time_raw);

	/* Base format of date column on nautilus date_format key */
	if (format_string != NULL) {
		if (strcmp(format_string, GSEARCH_DATE_FORMAT_LOCALE) == 0) {
			return gsearchtool_strdup_strftime ("%c", file_time);
		} else if (strcmp (format_string, GSEARCH_DATE_FORMAT_ISO) == 0) {
			return gsearchtool_strdup_strftime ("%Y-%m-%d %H:%M:%S", file_time);
		}
	}

	file_date = g_date_new_dmy (file_time->tm_mday,
			       file_time->tm_mon + 1,
			       file_time->tm_year + 1900);

	today = g_date_new ();
	g_date_set_time_t (today, time (NULL));

	file_date_age = g_date_get_julian (today) - g_date_get_julian (file_date);

	g_date_free (today);
	g_date_free (file_date);

	if (file_date_age == 0)	{
	/* Translators:  Below are the strings displayed in the 'Date Modified'
	   column of the list view.  The format of this string can vary depending
	   on age of a file.  Please modify the format of the timestamp to match
	   your locale.  For example, to display 24 hour time replace the '%-I'
	   with '%-H' and remove the '%p'.  (See bugzilla report #120434.) */
		format = g_strdup(_("today at %-I:%M %p"));
	} else if (file_date_age == 1) {
		format = g_strdup(_("yesterday at %-I:%M %p"));
	} else if (file_date_age < 7) {
		format = g_strdup(_("%A, %B %-d %Y at %-I:%M:%S %p"));
	} else {
		format = g_strdup(_("%A, %B %-d %Y at %-I:%M:%S %p"));
	}

	readable_date = gsearchtool_strdup_strftime (format, file_time);
	g_free (format);

	return readable_date;
}
示例#19
0
static int get_date_offset( GtkCalendar* calendar )
{
    /* FIXME: I think we need a better implementation for this */
    GDate* date;
    GDate* today;
    int y, m, d, offset;
    time_t timeval = time(NULL);
    struct tm* lt = localtime( &timeval );

    gtk_calendar_get_date( calendar, &y, &m, &d );

    date = g_date_new_dmy( d, m, y );
    today = g_date_new_dmy( lt->tm_mday, lt->tm_mon, lt->tm_year+1900 );

    offset = g_date_days_between( date, today );

    g_date_free(date);
    g_date_free(today);
    return ABS(offset);
}
示例#20
0
文件: utils_date.c 项目: rosedu/osmo
guint32
utl_date_dmy_to_julian (guint day, guint month, guint year)
{
	g_return_val_if_fail (g_date_valid_dmy (day, month, year), 0);

	GDate *d = g_date_new_dmy (day, month, year);
	guint32 julian = g_date_get_julian (d);
	g_date_free (d);

	return julian;
}
示例#21
0
文件: gnc-date.c 项目: 573/gnucash
GDate* gnc_g_date_new_today ()
{
     GDateTime *gdt = gnc_g_date_time_new_now_local ();
     gint day, month, year;
     GDate *result;

     g_date_time_get_ymd (gdt, &year, &month, &day);
     result = g_date_new_dmy (day, month, year);
     g_date_time_unref (gdt);
     g_assert(g_date_valid (result));

     return result;
}
示例#22
0
/**
 * convert ISO date to GDate
 */
GDate*
string_to_g_date (gchar *date_string)
{
	gchar **date_tokens = g_strsplit (date_string, "-", -1);

	gint year = strtol(date_tokens[0], NULL, 10);
	gint month = strtol(date_tokens[1], NULL, 10);
	gint day = strtol(date_tokens[2], NULL, 10);

	g_strfreev(date_tokens);

	return g_date_new_dmy ((GDateDay)day, (GDateMonth)month, (GDateYear)year);
}
示例#23
0
void
gnc_tree_util_split_reg_parse_date (GDate *parsed, const char *datestr)
{
    int day, month, year;
    gboolean use_autoreadonly = qof_book_uses_autoreadonly (gnc_get_current_book ());

    if (!parsed) return;
    if (!datestr) return;

    if (!qof_scan_date (datestr, &day, &month, &year))
    {
        // Couldn't parse date, use today
        struct tm tm_today;
        gnc_tm_get_today_start (&tm_today);
        day = tm_today.tm_mday;
        month = tm_today.tm_mon + 1;
        year = tm_today.tm_year + 1900;
    }

    // If we have an auto-read-only threshold, do not accept a date that is
    // older than the threshold.
    if (use_autoreadonly)
    {
        GDate *d = g_date_new_dmy (day, month, year);
        GDate *readonly_threshold = qof_book_get_autoreadonly_gdate (gnc_get_current_book());
        if (g_date_compare (d, readonly_threshold) < 0)
        {
            g_warning("Entered date %s is before the \"auto-read-only threshold\"; resetting to the threshold.", datestr);
#if 0
            GtkWidget *dialog = gtk_message_dialog_new (NULL,
                                                       0,
                                                       GTK_MESSAGE_ERROR,
                                                       GTK_BUTTONS_OK,
                                                       "%s", _("Cannot store a transaction at this date"));
            gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
                                                     "%s", _("The entered date of the new transaction is older than the \"Read-Only Threshold\" set for this book. "
                                                             "This setting can be changed in File -> Properties -> Accounts."));
            gtk_dialog_run (GTK_DIALOG (dialog));
            gtk_widget_destroy (dialog);
#endif

            // Reset the date to the threshold date
            day = g_date_get_day (readonly_threshold);
            month = g_date_get_month (readonly_threshold);
            year = g_date_get_year (readonly_threshold);
        }
        g_date_free (d);
        g_date_free (readonly_threshold);
    }
    g_date_set_dmy (parsed, day, month, year);
}
示例#24
0
static gchar *
unix_shadow_to_string (const gchar *value, const gchar *attname)
{
	/* value is the number of days since 1970-01-01 */
	gint64 i64;
	gchar *endptr [1];

	if (!value || !*value)
		return NULL;

	i64 = g_ascii_strtoll (value, endptr, 10);
	if (**endptr != '\0')
		return NULL;

	if ((i64 == -1) &&
	    (!strcmp (attname, "shadowInactive") ||
	     !strcmp (attname, "shadowMin") ||
	     !strcmp (attname, "shadowExpire")))
		return g_strdup (_("Non activated"));
	else if ((i64 == 99999) && !strcmp (attname, "shadowMax"))
		return g_strdup ("Always valid");
	if ((i64 >= G_MAXUINT) || (i64 < 0))
		return NULL;

	if (!strcmp (attname, "shadowMax") ||
	    !strcmp (attname, "shadowMin") ||
	    !strcmp (attname, "shadowInactive"))
		return NULL;

	GDate *date;
	date = g_date_new_dmy (1, 1, 1970);
	g_date_add_days (date, (guint) i64);
	if (! g_date_valid (date)) {
		g_date_free (date);
		return NULL;
	}

	GdaDataHandler *dh;
	GValue tvalue;
	gchar *str;
	 
	memset (&tvalue, 0, sizeof (GValue));
	g_value_init (&tvalue, G_TYPE_DATE);
	g_value_take_boxed (&tvalue, date);
	dh = gda_data_handler_get_default (G_TYPE_DATE);
	str = gda_data_handler_get_str_from_value (dh, &tvalue);
	g_value_reset (&tvalue);

	return str;
}
static GDate *
get_fy_end(void)
{
    QofBook *book;
    KvpFrame *book_frame;
    gint64 month, day;

    book = gnc_get_current_book();
    book_frame = qof_book_get_slots(book);
    month = kvp_frame_get_gint64(book_frame, "/book/fyear_end/month");
    day = kvp_frame_get_gint64(book_frame, "/book/fyear_end/day");
    if (g_date_valid_dmy(day, month, 2005 /* not leap year */))
        return g_date_new_dmy(day, month, G_DATE_BAD_YEAR);
    return NULL;
}
示例#26
0
static void
calendar_date_to_string (CalendarData *data,
			      char         *buffer,
			      gint          buff_len)
{
  GDate *date;
  guint year, month, day;

  gtk_calendar_get_date (GTK_CALENDAR(data->window),
			 &year, &month, &day);
  date = g_date_new_dmy (day, month + 1, year);
  g_date_strftime (buffer, buff_len-1, "%x", date);

  g_date_free (date);
}
示例#27
0
GDate *
sj_metadata_helper_scan_date (const char *date)
{
  int matched, year=1, month=1, day=1;

  if (date == NULL)
    return NULL;

  matched = sscanf (date, "%u-%u-%u", &year, &month, &day);
  if (matched >= 1) {
    return g_date_new_dmy ((day == 0) ? 1 : day, (month == 0) ? 1 : month, year);
  }

  return NULL;
}
示例#28
0
GDate *
gnc_period_select_get_date_base (GncPeriodSelect *period)
{
    GncPeriodSelectPrivate *priv;

    g_return_val_if_fail(period != NULL, NULL);
    g_return_val_if_fail(GNC_IS_PERIOD_SELECT(period), NULL);

    priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
    if (!priv->date_base)
        return NULL;
    return g_date_new_dmy(g_date_get_day(priv->date_base),
                          g_date_get_month(priv->date_base),
                          g_date_get_year(priv->date_base));
}
示例#29
0
文件: utils.c 项目: rosedu/osmo
gchar *
utl_get_day_name (guint day, gboolean short_name)
{
	static gchar buffer[BUFFER_SIZE];
	GDate *tmpdate = NULL;

	g_return_val_if_fail (day > 0 && day <= 31, buffer);

	tmpdate = g_date_new_dmy (day, 1, 2007);
	g_return_val_if_fail (tmpdate != NULL, buffer);

	g_date_strftime (buffer, BUFFER_SIZE, short_name ? "%a" : "%A", tmpdate);
	g_date_free (tmpdate);

	return buffer;
}
示例#30
0
/*  Get the current value of the fiscal year end setting from a
 *  GncPeriodSelect widget.  If the result is NULL then fiscal years
 *  are not currently supported.
 */
GDate *
gnc_period_select_get_fy_end (GncPeriodSelect *period)
{
    GncPeriodSelectPrivate *priv;
    priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);

    g_return_val_if_fail(period != NULL, NULL);
    g_return_val_if_fail(GNC_IS_PERIOD_SELECT(period), NULL);

    priv = GNC_PERIOD_SELECT_GET_PRIVATE(period);
    if (!priv->fy_end)
        return NULL;
    return g_date_new_dmy(g_date_get_day(priv->fy_end),
                          g_date_get_month(priv->fy_end),
                          G_DATE_BAD_YEAR);
}