Ejemplo n.º 1
0
gchar *midgard_timestamp_dup_string(const GValue *value) 
{
        g_assert(G_VALUE_HOLDS(value, MIDGARD_TYPE_TIMESTAMP));

	MidgardTimestamp *mt = (MidgardTimestamp *) g_value_get_boxed(value);
        return (gchar *)caltime_fmt(mt); 
}
Ejemplo n.º 2
0
gchar *midgard_timestamp_get_string_from_value (const GValue *value)
{
	g_assert(value != NULL);
	g_return_val_if_fail(G_VALUE_HOLDS(value, MGD_TYPE_TIMESTAMP), NULL);

	MidgardTimestamp *mt = (MidgardTimestamp *) g_value_get_boxed (value);

	return caltime_fmt(mt);
}
Ejemplo n.º 3
0
static void midgard_timestamp_transform_to_string(const GValue *src, GValue *dst)
{
	g_return_if_fail(G_VALUE_HOLDS_STRING(dst) &&
			G_VALUE_HOLDS(src, MGD_TYPE_TIMESTAMP));

	MidgardTimestamp *mt = (MidgardTimestamp *) g_value_get_boxed(src);	
	gchar *str_val = (gchar *)caltime_fmt(mt);

	g_value_take_string(dst, str_val);
}
Ejemplo n.º 4
0
static enum ud_tree_walk_stat
rt_tag_date (struct udoc *ud, struct udr_ctx *rc)
{
    char cbuf[CALTIME_FMT];
    struct caltime ct;
    struct buffer *buf = &rc->uc_out->uoc_buffer;

    caltime_local (&ct, &ud->ud_time_start.sec, 0, 0);
    buffer_put (buf, cbuf, caltime_fmt (cbuf, &ct));
    return 1;
}
Ejemplo n.º 5
0
static enum ud_tree_walk_stat
x_tag_date (struct udoc *ud, struct udr_ctx *render_ctx)
{
  char buf[CALTIME_FMT];
  struct caltime ct;
  struct buffer *out = &render_ctx->uc_out->uoc_buffer;

  caltime_local (&ct, &ud->ud_time_start.sec, 0, 0);
  buffer_put (out, buf, caltime_fmt (buf, &ct));
  return UD_TREE_OK;
}
Ejemplo n.º 6
0
Archivo: check.c Proyecto: fohr/libtai
main()
{
  struct tai t;
  struct tai t2;
  struct caltime ct;
  struct caltime ct2;
  int weekday;
  int yearday;
  int i;
  double packerr;

  if (leapsecs_init() == -1)
    printf("unable to init leapsecs\n");

  while (fgets(line,sizeof line,stdin))
    if (!caltime_scan(line,&ct))
      printf("unable to parse\n");
    else {
      caltime_tai(&ct,&t);
      caltime_utc(&ct2,&t,&weekday,&yearday);
      tai_pack(x,&t);
      tai_unpack(x,&t2);
      tai_sub(&t2,&t2,&t);
      packerr = tai_approx(&t2);
      for (i = 0;i < TAI_PACK;++i)
        printf("%2.2x",(unsigned long) (unsigned char) x[i]);
      if (packerr)
        printf(" packerr=%f",packerr);
      printf(" %03d  %s",yearday,dayname[weekday]);
      if (caltime_fmt((char *) 0,&ct2) + 1 < sizeof out) {
        out[caltime_fmt(out,&ct2)] = 0;
        printf(" %s",out);
      }
      printf("\n");
    }
  return(0);
}
Ejemplo n.º 7
0
int main(int argc, char** argv)
{
	const char* cmd;
	uint64_t tai;
	const char* iso;

	if (argc < 3) {
		usage();
		return(1);
	}

	cmd = argv[1];

	if (strcmp(cmd, "taiToIso") == 0) {
		struct caltime ct;
		struct tai t;
		char buf[128];
		int len;
		tai = _strtoui64(argv[2], NULL, 10);
		t.x = tai;
		caltime_utc(&ct, &t, 0, 0);
		len = caltime_fmt(buf, &ct);
		buf[len] = '\0';
		printf("ISO: %s\n", buf);
	}
	else if (strcmp(cmd, "isoToTai") == 0) {
		iso = argv[2];
	}
	else {
		usage();
		return(1);
	}



	return(0);
}
Ejemplo n.º 8
0
gchar *midgard_timestamp_get_string(MidgardTimestamp *mt)
{
	g_return_val_if_fail (mt != NULL, NULL);

	return caltime_fmt(mt);
}