コード例 #1
0
bool DateTime::is_same_minute(const DateTime& a, const DateTime& b)
{
    if (!is_same_day(a,b))
        return false;

    const auto adt = a.get();
    const auto bdt = b.get();
    return (g_date_time_get_hour(adt) == g_date_time_get_hour(bdt))
        && (g_date_time_get_minute(adt) == g_date_time_get_minute(bdt));
}
コード例 #2
0
static guint
calculate_seconds_until_next_minute (void)
{
  guint seconds;
  GTimeSpan diff;
  GDateTime * now;
  GDateTime * next;
  GDateTime * start_of_next;

  now = g_date_time_new_now_local ();
  next = g_date_time_add_minutes (now, 1);
  start_of_next = g_date_time_new_local (g_date_time_get_year (next),
                                         g_date_time_get_month (next),
                                         g_date_time_get_day_of_month (next),
                                         g_date_time_get_hour (next),
                                         g_date_time_get_minute (next),
                                         1);

  diff = g_date_time_difference (start_of_next, now);
  seconds = (diff + (G_TIME_SPAN_SECOND - 1)) / G_TIME_SPAN_SECOND;

  /* cleanup */
  g_date_time_unref (start_of_next);
  g_date_time_unref (next);
  g_date_time_unref (now);

  return seconds;
}
コード例 #3
0
gdouble
gsd_night_light_frac_day_from_dt (GDateTime *dt)
{
        return g_date_time_get_hour (dt) +
                (gdouble) g_date_time_get_minute (dt) / 60.f +
                (gdouble) g_date_time_get_second (dt) / 3600.f;
}
コード例 #4
0
ファイル: gcal-utils.c プロジェクト: fanyui/gnome-calendar
gboolean
datetime_is_date (GDateTime *dt)
{
  return g_date_time_get_hour (dt) == 0 &&
         g_date_time_get_minute (dt) == 0 &&
         g_date_time_get_seconds (dt) == 0;
}
コード例 #5
0
ファイル: shd-tgen-main.c プロジェクト: desphunter/shadow
static void _tgenmain_log(GLogLevelFlags level, const gchar* fileName, const gint lineNum, const gchar* functionName, const gchar* format, ...) {
    if(level > tgenLogFilterLevel) {
        return;
    }

    va_list vargs;
    va_start(vargs, format);

    gchar* fileStr = fileName ? g_path_get_basename(fileName) : g_strdup("n/a");
    const gchar* functionStr = functionName ? functionName : "n/a";

    GDateTime* dt = g_date_time_new_now_local();
    GString* newformat = g_string_new(NULL);

    g_string_append_printf(newformat, "%04i-%02i-%02i %02i:%02i:%02i %"G_GINT64_FORMAT".%06i [%s] [%s:%i] [%s] %s",
            g_date_time_get_year(dt), g_date_time_get_month(dt), g_date_time_get_day_of_month(dt),
            g_date_time_get_hour(dt), g_date_time_get_minute(dt), g_date_time_get_second(dt),
            g_date_time_to_unix(dt), g_date_time_get_microsecond(dt),
            _tgenmain_logLevelToString(level), fileStr, lineNum, functionName, format);

    gchar* message = g_strdup_vprintf(newformat->str, vargs);
    g_print("%s\n", message);
    g_free(message);

    g_string_free(newformat, TRUE);
    g_date_time_unref(dt);
    g_free(fileStr);

    va_end(vargs);
}
コード例 #6
0
void
gcal_time_selector_set_time (GcalTimeSelector *selector,
                             GDateTime        *time)
{
  g_return_if_fail (GCAL_IS_TIME_SELECTOR (selector));

  if (selector->time != time)
    {
      gint hour, minute;

      g_clear_pointer (&selector->time, g_date_time_unref);
      selector->time = g_date_time_new_local (g_date_time_get_year (time),
                                              g_date_time_get_month (time),
                                              g_date_time_get_day_of_month (time),
                                              g_date_time_get_hour (time),
                                              g_date_time_get_minute (time),
                                              0);

      /* Update the spinners */
      g_signal_handlers_block_by_func (selector->hour_adjustment, update_time, selector);
      g_signal_handlers_block_by_func (selector->minute_adjustment, update_time, selector);

      hour = g_date_time_get_hour (time);
      minute = g_date_time_get_minute (time);

      if (!selector->format_24h)
        {
          g_signal_handlers_block_by_func (selector->period_combo, update_time, selector);

          gtk_combo_box_set_active (GTK_COMBO_BOX (selector->period_combo), hour >= 12);
          hour =  hour % 12;
          hour = (hour == 0)? 12 : hour;

          g_signal_handlers_unblock_by_func (selector->period_combo, update_time, selector);
        }

      gtk_adjustment_set_value (selector->hour_adjustment, hour);
      gtk_adjustment_set_value (selector->minute_adjustment, minute);

      update_label (selector);

      g_signal_handlers_unblock_by_func (selector->hour_adjustment, update_time, selector);
      g_signal_handlers_unblock_by_func (selector->minute_adjustment, update_time, selector);

      g_object_notify (G_OBJECT (selector), "time");
    }
}
コード例 #7
0
ファイル: gstdatetime.c プロジェクト: like0403/gstreamer
/**
 * gst_date_time_get_minute:
 * @datetime: a #GstDateTime
 *
 * Retrieves the minute of the hour represented by @datetime in the gregorian
 * calendar.
 * Call gst_date_time_has_time() before, to avoid warnings.
 *
 * Return value: the minute of the hour
 */
gint
gst_date_time_get_minute (const GstDateTime * datetime)
{
  g_return_val_if_fail (datetime != NULL, 0);
  g_return_val_if_fail (gst_date_time_has_time (datetime), 0);

  return g_date_time_get_minute (datetime->datetime);
}
コード例 #8
0
ファイル: datetime.c プロジェクト: GnLWeB/balde
gchar*
balde_datetime_logging(GDateTime *dt)
{
    return g_strdup_printf("%02d/%s/%04d %02d:%02d:%02d",
        g_date_time_get_day_of_month(dt), months[g_date_time_get_month(dt) - 1],
        g_date_time_get_year(dt), g_date_time_get_hour(dt),
        g_date_time_get_minute(dt), g_date_time_get_second(dt));
}
コード例 #9
0
ファイル: datetime.c プロジェクト: GnLWeB/balde
gchar*
balde_datetime_rfc5322(GDateTime *dt)
{
    // datetime must be utc
    return g_strdup_printf("%s, %02d %s %04d %02d:%02d:%02d GMT",
        days[g_date_time_get_day_of_week(dt) - 1],
        g_date_time_get_day_of_month(dt), months[g_date_time_get_month(dt) - 1],
        g_date_time_get_year(dt), g_date_time_get_hour(dt),
        g_date_time_get_minute(dt), g_date_time_get_second(dt));
}
コード例 #10
0
ファイル: main.c プロジェクト: simbits/ClaudeGlass
static unsigned long get_frame_offset_day_now(GCContext *context, int day)
{
    GCConfig      *config = context->config;
    GDateTime     *dt     = g_date_time_new_now(config->timeZone);
    unsigned long  f      = get_frame_offset_day(context, day);

    f += (g_date_time_get_hour(dt) * 60 + g_date_time_get_minute(dt)) * get_frames_per_minute(context);

    g_date_time_unref(dt);

    return (f >= config->number_of_frames) ? 0 : f;
}
コード例 #11
0
ファイル: misc.c プロジェクト: nirvanan/Codefox
/* Get current time and copy to src. */
void
time_get_now (gchar *src)
{
    GDateTime *time;
    gint hr, mi, se;

    time = g_date_time_new_now_local ();
    hr = g_date_time_get_hour (time);
    mi = g_date_time_get_minute (time);
    se = g_date_time_get_second (time);

    g_sprintf (src, "%.2d:%.2d:%.2d: ", hr, mi, se);
}
コード例 #12
0
ファイル: gnc-date.c プロジェクト: 573/gnucash
static void
gnc_g_date_time_fill_struct_tm (GDateTime *gdt, struct tm* time)
{
     g_date_time_get_ymd (gdt, &(time->tm_year), &(time->tm_mon), &(time->tm_mday));
     time->tm_sec = g_date_time_get_second (gdt);
     time->tm_min = g_date_time_get_minute (gdt);
     time->tm_hour = g_date_time_get_hour (gdt);
     // Watch out: struct tm has wday=0..6 with Sunday=0, but GDateTime has wday=1..7 with Sunday=7.
     time->tm_wday = g_date_time_get_day_of_week (gdt) % 7;
     time->tm_yday = g_date_time_get_day_of_year (gdt);
     time->tm_isdst = g_date_time_is_daylight_savings (gdt);
     time->tm_year -= 1900;
     --time->tm_mon;
}
コード例 #13
0
ファイル: chat_log.c プロジェクト: backalor/profanity
GSList *
chat_log_get_previous(const gchar * const login, const gchar * const recipient,
    GSList *history)
{
    GTimeZone *tz = g_time_zone_new_local();

    GDateTime *now = g_date_time_new_now_local();
    GDateTime *log_date = g_date_time_new(tz,
        g_date_time_get_year(session_started),
        g_date_time_get_month(session_started),
        g_date_time_get_day_of_month(session_started),
        g_date_time_get_hour(session_started),
        g_date_time_get_minute(session_started),
        g_date_time_get_second(session_started));

    // get data from all logs from the day the session was started to today
    while (g_date_time_compare(log_date, now) != 1) {
        char *filename = _get_log_filename(recipient, login, log_date, FALSE);

        FILE *logp = fopen(filename, "r");
        char *line;
        if (logp != NULL) {
            GString *gs_header = g_string_new("");
            g_string_append_printf(gs_header, "%d/%d/%d:",
                g_date_time_get_day_of_month(log_date),
                g_date_time_get_month(log_date),
                g_date_time_get_year(log_date));
            char *header = strdup(gs_header->str);
            history = g_slist_append(history, header);
            g_string_free(gs_header, TRUE);

            while ((line = prof_getline(logp)) != NULL) {
                history = g_slist_append(history, line);
            }

            fclose(logp);
        }

        free(filename);
        GDateTime *next = g_date_time_add_days(log_date, 1);
        g_date_time_unref(log_date);
        log_date = g_date_time_ref(next);
    }

    g_time_zone_unref(tz);

    return history;
}
コード例 #14
0
/* Auxiliary methods */
static gboolean
update_grid_scroll_position (GcalWeekView *self)
{
  g_autoptr(GDateTime) week_start = NULL;
  g_autoptr(GDateTime) week_end = NULL;
  g_autoptr(GDateTime) now = NULL;
  GtkAdjustment *vadjustment;
  gdouble minutes, real_value;
  gdouble max, page, page_increment, value;

  /* While the scrolled window is not mapped, we keep waiting */
  if (!gtk_widget_get_realized (self->scrolled_window) ||
      !gtk_widget_get_mapped (self->scrolled_window))
    {
      GCAL_RETURN (G_SOURCE_CONTINUE);
    }

  now = g_date_time_new_now_local ();
  week_start = get_start_of_week (self->date);
  week_end = get_end_of_week (self->date);

  /* Don't animate when not today */
  if (datetime_compare_date (now, week_start) < 0 || datetime_compare_date (now, week_end) >= 0)
    GCAL_GOTO (out);

  vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (self->scrolled_window));
  minutes = g_date_time_get_hour (now) * 60 + g_date_time_get_minute (now);
  page = gtk_adjustment_get_page_size (vadjustment);
  max = gtk_adjustment_get_upper (vadjustment);

  real_value = max / MINUTES_PER_DAY * minutes - (page / 2.0);
  page_increment = gtk_adjustment_get_page_increment (vadjustment);
  value = gtk_adjustment_get_value (vadjustment);

  gtk_adjustment_set_page_increment (vadjustment, real_value - value);

  g_signal_emit_by_name (self->scrolled_window,
                         "scroll-child",
                         GTK_SCROLL_PAGE_FORWARD,
                         FALSE);

  gtk_adjustment_set_page_increment (vadjustment, page_increment);

out:
  self->scroll_grid_timeout_id = 0;
  GCAL_RETURN (G_SOURCE_REMOVE);
}
コード例 #15
0
static void _pcapmain_log(GLogLevelFlags level, const gchar* functionName, const gchar* format, ...) {
    va_list vargs;
    va_start(vargs, format);

    GDateTime* dt = g_date_time_new_now_local();
    GString* newformat = g_string_new(NULL);

    g_string_append_printf(newformat, "%04i-%02i-%02i %02i:%02i:%02i %"G_GINT64_FORMAT".%06i [%s] [%s] %s",
            g_date_time_get_year(dt), g_date_time_get_month(dt), g_date_time_get_day_of_month(dt),
            g_date_time_get_hour(dt), g_date_time_get_minute(dt), g_date_time_get_second(dt),
            g_date_time_to_unix(dt), g_date_time_get_microsecond(dt),
            _pcapmain_logLevelToString(level), functionName, format);
    g_logv(PCAP_LOG_DOMAIN, level, newformat->str, vargs);

    g_string_free(newformat, TRUE);
    g_date_time_unref(dt);

    va_end(vargs);
}
コード例 #16
0
ファイル: Logger.c プロジェクト: AuraLinux/aura-plank
static gchar* plank_services_logger_get_time (void) {
	gchar* result = NULL;
	GDateTime* now = NULL;
	GDateTime* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	gint _tmp4_ = 0;
	gchar* _tmp5_ = NULL;
	_tmp0_ = g_date_time_new_now_local ();
	now = _tmp0_;
	_tmp1_ = g_date_time_get_hour (now);
	_tmp2_ = g_date_time_get_minute (now);
	_tmp3_ = g_date_time_get_second (now);
	_tmp4_ = g_date_time_get_microsecond (now);
	_tmp5_ = g_strdup_printf ("%.2d:%.2d:%.2d.%.6d", _tmp1_, _tmp2_, _tmp3_, _tmp4_);
	result = _tmp5_;
	_g_date_time_unref0 (now);
	return result;
}
コード例 #17
0
static void
change_date (CcDateTimePanel *self)
{
  CcDateTimePanelPrivate *priv = self->priv;
  guint mon, y, d;
  GDateTime *old_date;

  old_date = priv->date;

  mon = 1 + gtk_combo_box_get_active (GTK_COMBO_BOX (W ("month-combobox")));
  y = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (W ("year-spinbutton")));
  d = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (W ("day-spinbutton")));

  priv->date = g_date_time_new_local (y, mon, d,
                                      g_date_time_get_hour (old_date),
                                      g_date_time_get_minute (old_date),
                                      g_date_time_get_second (old_date));
  g_date_time_unref (old_date);
  queue_set_datetime (self);
}
コード例 #18
0
static gboolean
redisplay_clock (gpointer data)
{
  GSource *source;
  GDateTime *now, *expiry;

  now = g_date_time_new_now_local ();
  g_print ("%02d:%02d\n",
	   g_date_time_get_hour (now),
	   g_date_time_get_minute (now));

  expiry = g_date_time_add_seconds (now, 60 - g_date_time_get_second (now));
  source = g_date_time_source_new (expiry, TRUE);
  g_source_set_callback (source, redisplay_clock, NULL, NULL);
  g_source_attach (source, NULL);
  g_source_unref (source);

  g_date_time_unref (expiry);
  g_date_time_unref (now);

  return FALSE;
}
コード例 #19
0
ファイル: gcal-utils.c プロジェクト: fanyui/gnome-calendar
icaltimetype*
datetime_to_icaltime (GDateTime *dt)
{
  icaltimetype *idt;

  if (!dt)
    return NULL;

  idt = g_new0 (icaltimetype, 1);

  idt->year = g_date_time_get_year (dt);
  idt->month = g_date_time_get_month (dt);
  idt->day = g_date_time_get_day_of_month (dt);
  idt->hour = g_date_time_get_hour (dt);
  idt->minute = g_date_time_get_minute (dt);
  idt->second = g_date_time_get_seconds (dt);
  idt->is_date = (idt->hour == 0 &&
                  idt->minute == 0 &&
                  idt->second == 0);

  return idt;
}
コード例 #20
0
/**
 * vik_datetime_edit_dialog:
 * @parent:         The parent window
 * @title:          The title to use for the dialog
 * @initial_time:   The inital date/time to be shown
 * @tz:             The #GTimeZone this dialog will operate in
 *
 * Returns: A time selected by the user via this dialog
 *          Even though a time of zero is notionally valid - consider it unlikely to be actually wanted!
 *          Thus if the time is zero then the dialog was cancelled or somehow an invalid date was encountered.
 */
time_t vik_datetime_edit_dialog ( GtkWindow *parent, const gchar *title, time_t initial_time, GTimeZone *tz )
{
	g_return_val_if_fail ( tz, 0 );

	GtkWidget *dialog = gtk_dialog_new_with_buttons ( title,
	                                                  parent,
	                                                  GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
	                                                  GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
	                                                  GTK_STOCK_OK,     GTK_RESPONSE_ACCEPT,
	                                                  NULL );

	gtk_dialog_set_default_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT );
	GtkWidget *response_w = NULL;
#if GTK_CHECK_VERSION (2, 20, 0)
	response_w = gtk_dialog_get_widget_for_response ( GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT );
#endif

	GtkWidget *label;
	GtkWidget *cal = gtk_calendar_new ();

	// Set according to the given date/time + timezone for display
	GDateTime *gdt_in = g_date_time_new_from_unix_utc ( (gint64)initial_time );
	GDateTime *gdt_tz = g_date_time_to_timezone ( gdt_in, tz );
	g_date_time_unref ( gdt_in );

	gtk_calendar_select_month ( GTK_CALENDAR(cal), g_date_time_get_month(gdt_tz)-1, g_date_time_get_year (gdt_tz) );
	gtk_calendar_select_day ( GTK_CALENDAR(cal), g_date_time_get_day_of_month(gdt_tz) );

	GtkWidget *hbox_time = gtk_hbox_new ( FALSE, 1 );

	label = gtk_label_new ( g_date_time_get_timezone_abbreviation(gdt_tz) );
	gtk_box_pack_start ( GTK_BOX(hbox_time), label, FALSE, FALSE, 5 );

	GtkWidget *sb_hours = gtk_spin_button_new_with_range ( 0.0, 23.0, 1.0 );
	gtk_box_pack_start ( GTK_BOX(hbox_time), sb_hours, FALSE, FALSE, 0 );
	gtk_spin_button_set_value ( GTK_SPIN_BUTTON(sb_hours), g_date_time_get_hour(gdt_tz) );
	g_signal_connect ( sb_hours, "output", G_CALLBACK(on_output), NULL );

	label = gtk_label_new ( ":" );
	gtk_box_pack_start ( GTK_BOX(hbox_time), label, FALSE, FALSE, 0 );

	GtkWidget *sb_minutes = gtk_spin_button_new_with_range ( 0.0, 59.0, 1.0 );
	gtk_box_pack_start ( GTK_BOX(hbox_time), sb_minutes, FALSE, FALSE, 0);
	gtk_spin_button_set_value ( GTK_SPIN_BUTTON(sb_minutes), g_date_time_get_minute(gdt_tz) );
	g_signal_connect ( sb_minutes, "output", G_CALLBACK(on_output), NULL );

	label = gtk_label_new ( ":" );
	gtk_box_pack_start(GTK_BOX(hbox_time), label, FALSE, FALSE, 0);

	GtkWidget *sb_seconds = gtk_spin_button_new_with_range ( 0.0, 59.0, 1.0 );
	gtk_box_pack_start ( GTK_BOX(hbox_time), sb_seconds, FALSE, FALSE, 0 );
	gtk_spin_button_set_value ( GTK_SPIN_BUTTON(sb_seconds), g_date_time_get_second(gdt_tz) );
	g_signal_connect ( sb_seconds, "output", G_CALLBACK(on_output), NULL );

	gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), cal, FALSE, FALSE, 0 );
	gtk_box_pack_start ( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), hbox_time, FALSE, FALSE, 5 );

	if ( response_w )
		gtk_widget_grab_focus ( response_w );

	g_date_time_unref ( gdt_tz );

	gtk_widget_show_all ( dialog );
	if ( gtk_dialog_run ( GTK_DIALOG(dialog) ) != GTK_RESPONSE_ACCEPT ) {
		gtk_widget_destroy ( dialog );
		return 0;
	}

	// Read values
	guint year = 0;
	guint month = 0;
	guint day = 0;
	guint hours = 0;
	guint minutes = 0;
	guint seconds = 0;

	gtk_calendar_get_date ( GTK_CALENDAR(cal), &year, &month, &day );
	hours = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(sb_hours) );
	minutes = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(sb_minutes) );
	seconds = gtk_spin_button_get_value_as_int ( GTK_SPIN_BUTTON(sb_seconds) );

	gtk_widget_destroy(dialog);

	time_t ans = initial_time;
	GDateTime *gdt_ans = g_date_time_new ( tz, year, month+1, day, hours, minutes, (gdouble)seconds );
	if ( gdt_ans ) {
		ans = g_date_time_to_unix ( gdt_ans );
		g_date_time_unref ( gdt_ans );
	}

	return ans;
}
コード例 #21
0
ファイル: gda-ldap-util.c プロジェクト: GNOME/libgda
BerValue *
gda_ldap_attr_g_value_to_value (LdapConnectionData *cdata, const GValue *cvalue)
{
	BerValue *bv;

	if (!cvalue)
		return NULL;

	bv = g_new (struct berval, 1);

	if (G_VALUE_TYPE (cvalue) == G_TYPE_STRING) {
		const gchar *cstr;
		cstr = g_value_get_string (cvalue);
		bv->bv_val = g_strdup (cstr);
		bv->bv_len = strlen (cstr);
	}
	else if (G_VALUE_TYPE (cvalue) == G_TYPE_DATE_TIME) {
		GDateTime *ts;
		gchar *str;
		ts = g_value_get_boxed (cvalue);
		if (g_date_time_get_second (ts) == (gint) g_date_time_get_seconds (ts)) {
			if (g_date_time_get_utc_offset (ts) == 0)
				str = g_strdup_printf ("%04d-%02d-%02dT%02d:%02d:%02d",
															 g_date_time_get_year (ts),
															 g_date_time_get_month (ts),
															 g_date_time_get_day_of_month (ts),
															 g_date_time_get_hour (ts),
															 g_date_time_get_minute (ts),
															 g_date_time_get_second (ts));
			else {
				str = g_strdup_printf ("%04d-%02d-%02dT%02d:%02d:%02d",
															 g_date_time_get_year (ts),
															 g_date_time_get_month (ts),
															 g_date_time_get_day_of_month (ts),
															 g_date_time_get_hour (ts),
															 g_date_time_get_minute (ts),
															 g_date_time_get_second (ts));
				TO_IMPLEMENT;
			}
		}
		else {
			if (g_date_time_get_utc_offset (ts) == 0)
				str = g_strdup_printf ("%04d-%02d-%02dT%02d:%02d:%02d,%lu",
															 g_date_time_get_year (ts),
															 g_date_time_get_month (ts),
															 g_date_time_get_day_of_month (ts),
															 g_date_time_get_hour (ts),
															 g_date_time_get_minute (ts),
															 g_date_time_get_second (ts),
															 (gulong) ((g_date_time_get_seconds (ts) - g_date_time_get_second (ts)) * 1000000.0));
			else {
				str = g_strdup_printf ("%04d-%02d-%02dT%02d:%02d:%02d,%lu",
															 g_date_time_get_year (ts),
															 g_date_time_get_month (ts),
															 g_date_time_get_day_of_month (ts),
															 g_date_time_get_hour (ts),
															 g_date_time_get_minute (ts),
															 g_date_time_get_second (ts),
															 (gulong) ((g_date_time_get_seconds (ts) - g_date_time_get_second (ts)) * 1000000.0));
				TO_IMPLEMENT;
			}
		}
		bv->bv_val = str;
		bv->bv_len = strlen (str);
	}
	else if (G_VALUE_TYPE (cvalue) == G_TYPE_DATE) {
		GDate *date;
		gchar *str;
		date = (GDate*) g_value_get_boxed (cvalue);
		str = g_strdup_printf ("%04d-%02d-%02d", g_date_get_year (date), g_date_get_month (date),
				       g_date_get_day (date));
		bv->bv_val = str;
		bv->bv_len = strlen (str);
	}
	else if (G_VALUE_TYPE (cvalue) == GDA_TYPE_NULL) {
		bv->bv_val = NULL;
		bv->bv_len = 0;
	}
	else if (G_VALUE_TYPE (cvalue) == GDA_TYPE_BINARY) {
		TO_IMPLEMENT;
	}
	else if (G_VALUE_TYPE (cvalue) == GDA_TYPE_BLOB) {
		TO_IMPLEMENT;
	}
	else {
		gchar *str;
		str = gda_value_stringify (cvalue);
		bv->bv_val = str;
		bv->bv_len = strlen (str);
	}
	return bv;
}
コード例 #22
0
ファイル: gstdatetime.c プロジェクト: AlerIl/gstreamer0.10
gint
gst_date_time_get_minute (const GstDateTime * datetime)
{
  return g_date_time_get_minute (datetime->datetime);
}
コード例 #23
0
static void
set_time (GstRTSPTime * time, GstRTSPTime2 * time2, GstRTSPRangeUnit unit,
    GstClockTime clock_time)
{
  memset (time, 0, sizeof (GstRTSPTime));
  memset (time2, 0, sizeof (GstRTSPTime2));

  if (clock_time == GST_CLOCK_TIME_NONE) {
    time->type = GST_RTSP_TIME_END;
    return;
  }

  switch (unit) {
    case GST_RTSP_RANGE_SMPTE:
    case GST_RTSP_RANGE_SMPTE_30_DROP:
    {
      time->seconds = (guint64) (clock_time / GST_SECOND);
      time2->frames = 30003 * (clock_time % GST_SECOND) /
          (gdouble) (1001 * GST_SECOND);
      time->type = GST_RTSP_TIME_FRAMES;
      g_assert (time2->frames < 30);
      break;
    }
    case GST_RTSP_RANGE_SMPTE_25:
    {
      time->seconds = (guint64) (clock_time / GST_SECOND);
      time2->frames = (25 * (clock_time % GST_SECOND)) / (gdouble) GST_SECOND;
      time->type = GST_RTSP_TIME_FRAMES;
      g_assert (time2->frames < 25);
      break;
    }
    case GST_RTSP_RANGE_NPT:
    {
      time->seconds = (gdouble) clock_time / (gdouble) GST_SECOND;
      time->type = GST_RTSP_TIME_SECONDS;
      break;
    }
    case GST_RTSP_RANGE_CLOCK:
    {
      GDateTime *bt, *datetime;
      GstClockTime subsecond = clock_time % GST_SECOND;

      bt = g_date_time_new_utc (1900, 1, 1, 0, 0, 0.0);
      datetime = g_date_time_add_seconds (bt, clock_time / GST_SECOND);

      time2->year = g_date_time_get_year (datetime);
      time2->month = g_date_time_get_month (datetime);
      time2->day = g_date_time_get_day_of_month (datetime);

      time->seconds = g_date_time_get_hour (datetime) * 60 * 60;
      time->seconds += g_date_time_get_minute (datetime) * 60;
      time->seconds += g_date_time_get_seconds (datetime);
      time->seconds += (gdouble) subsecond / (gdouble) GST_SECOND;
      time->type = GST_RTSP_TIME_UTC;

      g_date_time_unref (bt);
      g_date_time_unref (datetime);
      break;
    }
  }

  if (time->seconds < 0.000000001)
    time->seconds = 0;
  if (time2->frames < 0.000000001)
    time2->frames = 0;
}
コード例 #24
0
ファイル: log.c プロジェクト: FabianHahn/shoveler
static char *formatLogMessage(const char *file, int line, ShovelerLogLevel level, const char *message)
{
	const char *strippedLocation = strstr(file, logLocationPrefix);
	if(strippedLocation != NULL) {
		strippedLocation += strlen(logLocationPrefix);
	} else {
		strippedLocation = file;
	}

	GDateTime *now = g_date_time_new_now_local();
	GString *result = g_string_new("");

	g_string_append_printf(result, "[%02d:%02d:%02d] (%s:%s:%d) %s", g_date_time_get_hour(now), g_date_time_get_minute(now), g_date_time_get_second(now), getStaticLogLevelName(level), strippedLocation, line, message);

	g_date_time_unref(now);
	return g_string_free(result, false);
}
コード例 #25
0
static gint
g_calendar_gregorian_real_get_minute (GCalendar *calendar, /* IN */
                                      GDateTime *datetime) /* IN */
{
  return g_date_time_get_minute (datetime);
}
コード例 #26
0
int DateTime::minute() const
{
    return g_date_time_get_minute(get());
}
コード例 #27
0
/* Update the widgets based on the system time */
static void
update_time (CcDateTimePanel *self)
{
  CcDateTimePanelPrivate *priv = self->priv;
  GtkWidget *h_spinbutton;
  GtkWidget *m_spinbutton;
  GtkWidget *am_pm_button;
  char *label;
  gint hour;
  gint minute;
  gboolean use_ampm;

  h_spinbutton = W("h_spinbutton");
  m_spinbutton = W("m_spinbutton");
  am_pm_button = W("am_pm_button");

  g_signal_handlers_block_by_func (h_spinbutton, change_time, self);
  g_signal_handlers_block_by_func (m_spinbutton, change_time, self);
  g_signal_handlers_block_by_func (am_pm_button, am_pm_button_clicked, self);

  if (priv->clock_format == G_DESKTOP_CLOCK_FORMAT_12H)
    use_ampm = TRUE;
  else
    use_ampm = FALSE;

  hour = g_date_time_get_hour (priv->date);
  minute = g_date_time_get_minute (priv->date);

  if (!use_ampm)
    {
      /* Update the hours spinbutton */
      gtk_spin_button_set_range (GTK_SPIN_BUTTON (h_spinbutton), 0, 23);
      gtk_spin_button_set_value (GTK_SPIN_BUTTON (h_spinbutton), hour);
    }
  else
    {
      gboolean is_pm_time;

      is_pm_time = (hour >= 12);

      /* Update the AM/PM button */
      if (is_pm_time)
        gtk_stack_set_visible_child (GTK_STACK (priv->am_pm_stack), priv->pm_label);
      else
        gtk_stack_set_visible_child (GTK_STACK (priv->am_pm_stack), priv->am_label);

      /* Update the hours spinbutton */
      if (is_pm_time)
        hour -= 12;
      if (hour == 0)
        hour = 12;
      gtk_spin_button_set_value (GTK_SPIN_BUTTON (h_spinbutton), hour);
      gtk_spin_button_set_range (GTK_SPIN_BUTTON (h_spinbutton), 1, 12);
    }

  gtk_widget_set_visible (am_pm_button, use_ampm);

  /* Update the minutes spinbutton */
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (m_spinbutton), minute);

  g_signal_handlers_unblock_by_func (h_spinbutton, change_time, self);
  g_signal_handlers_unblock_by_func (m_spinbutton, change_time, self);
  g_signal_handlers_unblock_by_func (am_pm_button, am_pm_button_clicked, self);

  /* Update the time on the listbow row */
  if (use_ampm)
    {
      /* Translators: This is the full date and time format used in 12-hour mode. */
      label = g_date_time_format (priv->date, _("%e %B %Y, %l:%M %p"));
    }
  else
    {
      /* Translators: This is the full date and time format used in 24-hour mode. */
      label = g_date_time_format (priv->date, _("%e %B %Y, %R"));
    }

  gtk_label_set_text (GTK_LABEL (W ("datetime_label")), label);
  g_free (label);
}