예제 #1
0
파일: time.c 프로젝트: carsonmcdonald/mruby
/* Creates an instance of time at the given time in local time zone. */
static mrb_value
mrb_time_local(mrb_state *mrb, mrb_value self)
{
  mrb_int ayear = 0, amonth = 1, aday = 1, ahour = 0, amin = 0, asec = 0, ausec = 0;

  mrb_get_args(mrb, "i|iiiiii",
                &ayear, &amonth, &aday, &ahour, &amin, &asec, &ausec);
  return mrb_time_wrap(mrb, mrb_class_ptr(self),
          time_mktime(mrb, ayear, amonth, aday, ahour, amin, asec, ausec, MRB_TIMEZONE_LOCAL));
}
예제 #2
0
파일: time.c 프로젝트: Asmod4n/mruby
/* Returns the Time object of the LOCAL timezone. */
static mrb_value
mrb_time_getlocal(mrb_state *mrb, mrb_value self)
{
  struct mrb_time *tm, *tm2;

  tm = DATA_GET_PTR(mrb, self, &mrb_time_type, struct mrb_time);
  tm2 = (struct mrb_time *)mrb_malloc(mrb, sizeof(*tm));
  *tm2 = *tm;
  tm2->timezone = MRB_TIMEZONE_LOCAL;
  mrb_time_update_datetime(tm2);
  return mrb_time_wrap(mrb, mrb_obj_class(mrb, self), tm2);
}
예제 #3
0
파일: time.c 프로젝트: galois17/mruby
/* Returns the Time object of the UTC(GMT) timezone. */
static mrb_value
mrb_time_getutc(mrb_state *mrb, mrb_value self)
{
  struct mrb_time *tm, *tm2;

  tm = (struct mrb_time *)mrb_get_datatype(mrb, self, &mrb_time_type);
  if (!tm) return self;
  tm2 = (struct mrb_time *)mrb_malloc(mrb, sizeof(*tm));
  *tm2 = *tm;
  tm2->timezone = MRB_TIMEZONE_UTC;
  mrb_time_update_datetime(tm2);
  return mrb_time_wrap(mrb, mrb_obj_class(mrb, self), tm2);
}
예제 #4
0
파일: time.c 프로젝트: Asmod4n/mruby
/* Allocates a new Time object with given millis value. */
static mrb_value
mrb_time_now(mrb_state *mrb, mrb_value self)
{
  return mrb_time_wrap(mrb, mrb_class_ptr(self), current_mrb_time(mrb));
}
예제 #5
0
파일: time.c 프로젝트: Asmod4n/mruby
static mrb_value
mrb_time_make(mrb_state *mrb, struct RClass *c, double sec, double usec, enum mrb_timezone timezone)
{
  return mrb_time_wrap(mrb, c, time_alloc(mrb, sec, usec, timezone));
}
예제 #6
0
static mrb_value
mrb_time_make(mrb_state *mrb, struct RClass *c, mrb_float seconds, enum mrb_timezone timezone)
{
  return mrb_time_wrap(mrb, c, mrb_time_alloc(mrb, seconds, timezone));
}