本文整理汇总了C++中rb_time_new函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_time_new函数的具体用法?C++ rb_time_new怎么用?C++ rb_time_new使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_time_new函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rb_git_indexentry_fromC
static VALUE rb_git_indexentry_fromC(const git_index_entry *entry)
{
VALUE rb_entry, rb_mtime, rb_ctime;
unsigned int valid, stage;
if (!entry)
return Qnil;
rb_entry = rb_hash_new();
rb_hash_aset(rb_entry, CSTR2SYM("path"), rb_str_new_utf8(entry->path));
rb_hash_aset(rb_entry, CSTR2SYM("oid"), rugged_create_oid(&entry->id));
rb_hash_aset(rb_entry, CSTR2SYM("dev"), INT2FIX(entry->dev));
rb_hash_aset(rb_entry, CSTR2SYM("ino"), INT2FIX(entry->ino));
rb_hash_aset(rb_entry, CSTR2SYM("mode"), INT2FIX(entry->mode));
rb_hash_aset(rb_entry, CSTR2SYM("gid"), INT2FIX(entry->gid));
rb_hash_aset(rb_entry, CSTR2SYM("uid"), INT2FIX(entry->uid));
rb_hash_aset(rb_entry, CSTR2SYM("file_size"), INT2FIX(entry->file_size));
valid = (entry->flags & GIT_IDXENTRY_VALID);
rb_hash_aset(rb_entry, CSTR2SYM("valid"), valid ? Qtrue : Qfalse);
stage = (entry->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT;
rb_hash_aset(rb_entry, CSTR2SYM("stage"), INT2FIX(stage));
rb_mtime = rb_time_new(entry->mtime.seconds, entry->mtime.nanoseconds / 1000);
rb_ctime = rb_time_new(entry->ctime.seconds, entry->ctime.nanoseconds / 1000);
rb_hash_aset(rb_entry, CSTR2SYM("ctime"), rb_ctime);
rb_hash_aset(rb_entry, CSTR2SYM("mtime"), rb_mtime);
return rb_entry;
}
示例2: parse_double_time
static VALUE
parse_double_time(const char *text) {
long v = 0;
long v2 = 0;
const char *dot = 0;
char c;
for (; '.' != *text; text++) {
c = *text;
if (c < '0' || '9' < c) {
return Qnil;
}
v = 10 * v + (long)(c - '0');
}
dot = text++;
for (; '\0' != *text && text - dot <= 6; text++) {
c = *text;
if (c < '0' || '9' < c) {
return Qnil;
}
v2 = 10 * v2 + (long)(c - '0');
}
for (; text - dot <= 9; text++) {
v2 *= 10;
}
#if HAS_NANO_TIME
return rb_time_nano_new(v, v2);
#else
return rb_time_new(v, v2 / 1000);
#endif
}
示例3: t_get_loop_time
static VALUE t_get_loop_time (VALUE self)
{
if (gCurrentLoopTime != 0) {
return rb_time_new(gCurrentLoopTime / 1000000, gCurrentLoopTime % 1000000);
}
return Qnil;
}
示例4: rrrd_rrd_last_update
static VALUE rrrd_rrd_last_update(VALUE self) {
list arguments = rrrd_list_new();
rrrd_add_filename_arg(self, &arguments);
time_t last_update;
unsigned long ds_count;
char **raw_names, **last_ds;
rrd_lastupdate(arguments.length, arguments.strings, &last_update, &ds_count, &raw_names, &last_ds);
rrrd_free_arguments(arguments);
rrrd_check_for_errors();
VALUE timestamp = rb_time_new(last_update, 0);
VALUE values = rb_hash_new();
int i;
for (i = 0; i < ds_count; i++) {
VALUE key = ID2SYM(rb_intern(raw_names[i]));
VALUE value = rb_funcall(rb_str_new2(last_ds[i]), rb_intern("to_f"), 0);
rb_hash_aset(values, key, value);
}
VALUE args[] = { timestamp, values };
VALUE tuple = rb_class_new_instance(2, args, Tuple);
return tuple;
}
示例5: des0_read_time
static VALUE des0_read_time(AMF_DESERIALIZER *des) {
double milli = des_read_double(des);
des_read_uint16(des); // Timezone - unused
time_t sec = milli/1000.0;
time_t micro = (milli-sec*1000)*1000;
return rb_time_new(sec, micro);
}
示例6: rugged_signature_new
VALUE rugged_signature_new(const git_signature *sig, const char *encoding_name)
{
VALUE rb_sig, rb_time;
rb_encoding *encoding = rb_utf8_encoding();
if (encoding_name != NULL)
encoding = rb_enc_find(encoding_name);
rb_sig = rb_hash_new();
/* Allocate the time with a the given timezone */
rb_time = rb_funcall(
rb_time_new(sig->when.time, 0),
rb_intern("getlocal"), 1,
INT2FIX(sig->when.offset * 60)
);
rb_hash_aset(rb_sig, CSTR2SYM("name"),
rb_enc_str_new(sig->name, strlen(sig->name), encoding));
rb_hash_aset(rb_sig, CSTR2SYM("email"),
rb_enc_str_new(sig->email, strlen(sig->email), encoding));
rb_hash_aset(rb_sig, CSTR2SYM("time"), rb_time);
return rb_sig;
}
示例7: des0_read_time
static VALUE des0_read_time(VALUE self) {
AMF_DESERIALIZER *des;
Data_Get_Struct(self, AMF_DESERIALIZER, des);
double milli = des_read_double(des);
des_read_uint16(des); // Timezone - unused
time_t sec = milli/1000.0;
time_t micro = (milli-sec*1000)*1000;
return rb_time_new(sec, micro);
}
示例8: rrrd_rrd_last
static VALUE rrrd_rrd_last(VALUE self) {
list arguments = rrrd_list_new();
rrrd_add_filename_arg(self, &arguments);
time_t last = rrd_last(arguments.length, arguments.strings);
rrrd_free_arguments(arguments);
rrrd_check_for_errors();
return rb_time_new(last, 0);
}
示例9: rb_read_date
STATIC VALUE rb_read_date(ramf0_load_context_t* context)
{
double seconds_f = c_read_double(context) / 1000.0;
uint16_t tz = c_read_word16_network(context);
time_t seconds = seconds_f;
time_t microseconds = (seconds_f - (double)seconds) * (1000.0 * 1000.0);
return rb_time_new(seconds, microseconds);
}
示例10: method_boot_time
VALUE method_boot_time(VALUE self) {
struct timeval tv;
size_t size = sizeof(tv);
static int which[] = { CTL_KERN, KERN_BOOTTIME };
if (sysctl(which, 2, &tv, &size, NULL, 0) == 0) {
return rb_time_new(tv.tv_sec, tv.tv_usec);
} else {
return Qnil;
}
}
示例11: bf_get_visited
static VALUE
bf_get_visited(VALUE self, VALUE uri)
{
GError *error = NULL;
time_t ret = g_bookmark_file_get_visited(_SELF(self),
(const gchar *)RVAL2CSTR(uri),
&error);
if (!ret) RAISE_GERROR(error);
return rb_time_new(ret, 0);
}
示例12: data_objects_debug
static void data_objects_debug(VALUE connection, VALUE string, struct timeval* start) {
struct timeval stop;
VALUE message;
gettimeofday(&stop, NULL);
do_int64 duration = (stop.tv_sec - start->tv_sec) * 1000000 + stop.tv_usec - start->tv_usec;
message = rb_funcall(cDO_Logger_Message, DO_ID_NEW, 3, string, rb_time_new(start->tv_sec, start->tv_usec), INT2NUM(duration));
rb_funcall(connection, DO_ID_LOG, 1, message);
}
示例13: parse_xsd_time
static VALUE
parse_xsd_time(const char *text) {
long cargs[10];
long *cp = cargs;
long v;
int i;
char c = '\0';
struct _tp tpa[10] = { { 4, '-', '-' },
{ 2, '-', '-' },
{ 2, 'T', ' ' },
{ 2, ':', ':' },
{ 2, ':', ':' },
{ 2, '.', '.' },
{ 9, '+', '-' },
{ 2, ':', ':' },
{ 2, '\0', '\0' },
{ 0, '\0', '\0' } };
Tp tp = tpa;
struct tm tm;
memset(cargs, 0, sizeof(cargs));
for (; 0 != tp->cnt; tp++) {
for (i = tp->cnt, v = 0; 0 < i ; text++, i--) {
c = *text;
if (c < '0' || '9' < c) {
if ('\0' == c || tp->end == c || tp->alt == c) {
break;
}
return Qnil;
}
v = 10 * v + (long)(c - '0');
}
if ('\0' == c) {
break;
}
c = *text++;
if (tp->end != c && tp->alt != c) {
return Qnil;
}
*cp++ = v;
}
tm.tm_year = (int)cargs[0] - 1900;
tm.tm_mon = (int)cargs[1] - 1;
tm.tm_mday = (int)cargs[2];
tm.tm_hour = (int)cargs[3];
tm.tm_min = (int)cargs[4];
tm.tm_sec = (int)cargs[5];
#if HAS_NANO_TIME
return rb_time_nano_new(mktime(&tm), cargs[6]);
#else
return rb_time_new(mktime(&tm), cargs[6] / 1000);
#endif
}
示例14: occurrences
VALUE occurrences( VALUE self, VALUE dtstart, VALUE dtend, VALUE rrule ) {
char * _rrule;
struct icaltimetype start, end;
time_t tt;
VALUE tv_sec, occurr = rb_ary_new();
/* Get method ID for Time.tv_sec */
ID time_tv_sec = rb_intern( "tv_sec" );
ID to_string = rb_intern( "to_string" );
if( TYPE( rrule ) != T_STRING && rb_respond_to( rrule, to_string ) )
rrule = rb_funcall( rrule, to_string, 0 );
Check_Type(rrule, T_STRING);
_rrule = RSTRING(rrule)->ptr;
dtstart = to_time( dtstart, "dtstart" );
dtend = to_time( dtend, "dtend" );
/* Apply .tv_sec to our Time objects (if they are Times ...) */
tv_sec = rb_funcall( dtstart, time_tv_sec, 0 );
tt = NUM2INT( tv_sec );
start = icaltime_from_timet( tt, 0 );
tv_sec = rb_funcall( dtend, time_tv_sec, 0 );
tt = NUM2INT( tv_sec );
end = icaltime_from_timet( tt, 0 );
icalerror_clear_errno();
icalerror_set_error_state( ICAL_MALFORMEDDATA_ERROR, ICAL_ERROR_NONFATAL);
struct icalrecurrencetype recur = icalrecurrencetype_from_string( _rrule );
if( icalerrno != ICAL_NO_ERROR ) {
rb_raise(rb_eArgError, "Malformed RRule");
return Qnil;
}
icalrecur_iterator* ritr = icalrecur_iterator_new( recur, start );
while(1) {
struct icaltimetype next = icalrecur_iterator_next(ritr);
if( icaltime_is_null_time(next) || ( icaltime_compare( next, end ) > 0 ) ) {
icalrecur_iterator_free(ritr);
return occurr;
}
rb_ary_push( occurr, rb_time_new( icaltime_as_timet( next ), 0 ) );
};
icalrecur_iterator_free(ritr);
return occurr;
}
示例15: bf_get_app_info
static VALUE
bf_get_app_info(VALUE self, VALUE uri, VALUE name)
{
gchar* exec;
guint count;
time_t stamp;
GError* error = NULL;
gboolean ret = g_bookmark_file_get_app_info(_SELF(self),
(const gchar *)RVAL2CSTR(uri),
(const gchar *)RVAL2CSTR(name),
&exec, &count, &stamp, &error);
if (!ret) RAISE_GERROR(error);
return rb_ary_new3(3, CSTR2RVAL(exec), UINT2NUM(count), rb_time_new(stamp, 0));
}