本文整理汇总了C++中rb_time_new函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_time_new函数的具体用法?C++ rb_time_new怎么用?C++ rb_time_new使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_time_new函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:mkanoor,项目名称:rugged,代码行数:34,代码来源:rugged_index.c
示例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
}
开发者ID:ohler55,项目名称:ox,代码行数:31,代码来源:sax_as.c
示例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;
}
开发者ID:bernd,项目名称:eventmachine,代码行数:7,代码来源:rubymain.cpp
示例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;
}
开发者ID:tylerhunt,项目名称:rrrd,代码行数:28,代码来源:rrrd.c
示例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);
}
开发者ID:ryanwilliams,项目名称:rocket-amf,代码行数:7,代码来源:deserializer.c
示例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;
}
开发者ID:Angolier,项目名称:sonic-pi,代码行数:27,代码来源:rugged_signature.c
示例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);
}
开发者ID:qianthinking,项目名称:rocketamf,代码行数:9,代码来源:deserializer.c
示例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);
}
开发者ID:tylerhunt,项目名称:rrrd,代码行数:10,代码来源:rrrd.c
示例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);
}
开发者ID:mrhenry,项目名称:ramf,代码行数:10,代码来源:ramf_AMF0Deserializer.c
示例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;
}
}
开发者ID:pedrocarrico,项目名称:ruby-vmstat,代码行数:11,代码来源:vmstat.c
示例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);
}
开发者ID:benolee,项目名称:ruby-gnome2,代码行数:11,代码来源:rbglib_bookmarkfile.c
示例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);
}
开发者ID:datamapper,项目名称:do,代码行数:11,代码来源:do_oracle.c
示例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
}
开发者ID:ohler55,项目名称:ox,代码行数:53,代码来源:sax_as.c
示例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;
}
开发者ID:erdgeist,项目名称:chaoscalendar,代码行数:53,代码来源:chaos_calendar.c
示例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));
}
开发者ID:benolee,项目名称:ruby-gnome2,代码行数:16,代码来源:rbglib_bookmarkfile.c
示例16: t_get_loop_time
static VALUE t_get_loop_time (VALUE self)
{
#ifndef HAVE_RB_TIME_NEW
static VALUE cTime = rb_path2class("Time");
static ID at = rb_intern("at");
#endif
uint64_t current_time = evma_get_current_loop_time();
if (current_time != 0) {
#ifndef HAVE_RB_TIME_NEW
return rb_funcall(cTime, at, 2, INT2NUM(current_time / 1000000), INT2NUM(current_time % 1000000));
#else
return rb_time_new(current_time / 1000000, current_time % 1000000);
#endif
}
return Qnil;
}
开发者ID:MitulMistry,项目名称:sinatra-sessions-v-000,代码行数:17,代码来源:rubymain.cpp
示例17: cf_hash_to_rb_hash
static void cf_hash_to_rb_hash(const void *raw_key, const void * raw_value, void *ctx){
CFTypeRef value = (CFTypeRef)raw_value;
CFStringRef key = (CFStringRef)raw_key;
VALUE rubyValue = Qnil;
VALUE hash = (VALUE)ctx;
if(CFStringGetTypeID() == CFGetTypeID(value)){
rubyValue = cfstring_to_rb_string((CFStringRef)value);
}
else if(CFDataGetTypeID() == CFGetTypeID(value)){
CFDataRef data = (CFDataRef)value;
rubyValue = rb_enc_str_new((const char*)CFDataGetBytePtr(data),CFDataGetLength(data), rb_ascii8bit_encoding());
}
else if(CFBooleanGetTypeID() == CFGetTypeID(value)){
Boolean booleanValue = CFBooleanGetValue(value);
rubyValue = booleanValue ? Qtrue : Qfalse;
}
else if(CFNumberGetTypeID() == CFGetTypeID(value)){
if(CFNumberIsFloatType(value))
{
double doubleValue;
CFNumberGetValue(value, kCFNumberDoubleType, &doubleValue);
rubyValue = rb_float_new(doubleValue);
}else{
long long longValue;
CFNumberGetValue(value, kCFNumberLongLongType, &longValue);
rubyValue = LL2NUM(longValue);
}
}
else if (CFDateGetTypeID() == CFGetTypeID(value)){
CFDateRef date = (CFDateRef) value;
CFAbsoluteTime abs_time = CFDateGetAbsoluteTime(date);
double secondsSinceUnixEpoch = abs_time + kCFAbsoluteTimeIntervalSince1970;
time_t seconds = (time_t)secondsSinceUnixEpoch;
long usec = (secondsSinceUnixEpoch - seconds) * 1000000;
rubyValue = rb_time_new((time_t)secondsSinceUnixEpoch, usec);
}
if(!NIL_P(rubyValue)){
rb_hash_aset(hash, cfstring_to_rb_string(key), rubyValue);
}
}
开发者ID:fcheung,项目名称:keychain_c,代码行数:43,代码来源:keychain.c
示例18: rb_rcsrev_new
static VALUE
rb_rcsrev_new(struct rcsrev *rev)
{
struct tm tm;
const char *month;
VALUE self;
VALUE date;
memset(&tm, 0, sizeof(tm));
if (rev->date->len == 17) {
/* 2-digit year */
readdate(rev->date->str, &tm.tm_year, 2);
month = rev->date->str + 3;
} else {
/* 4-digit year */
readdate(rev->date->str, &tm.tm_year, 4);
tm.tm_year -= 1900;
month = rev->date->str + 5;
}
readdate(month, &tm.tm_mon, 2);
tm.tm_mon--;
readdate(month + 3, &tm.tm_mday, 2);
readdate(month + 6, &tm.tm_hour, 2);
readdate(month + 9, &tm.tm_min, 2);
readdate(month + 12, &tm.tm_sec, 2);
date = rb_time_new(timegm(&tm), 0);
/*
* rb_time_new returns a Time object in local time, so convert
* it to GMT, what RCS/CVS uses everywhere.
*/
date = rb_funcall(date, rb_intern("gmtime"), 0);
self = rb_obj_alloc(rb_cRev);
rb_iv_set(self, "@rev", str_from_tok(rev->rev));
rb_iv_set(self, "@date", date);
rb_iv_set(self, "@author", str_from_tok(rev->author));
rb_iv_set(self, "@state", str_from_tok2(rev->state));
rb_iv_set(self, "@branches", ary_from_toklist(&rev->branches));
rb_iv_set(self, "@next", str_from_tok2(rev->next));
rb_iv_set(self, "@commitid", str_from_tok2(rev->commitid));
return self;
}
开发者ID:comutt,项目名称:rcsparse,代码行数:43,代码来源:rb-rcsparse.c
示例19: rrrd_rrd_first
static VALUE rrrd_rrd_first(int argc, VALUE *argv, VALUE self) {
VALUE index;
rb_scan_args(argc, argv, "01", &index);
list arguments = rrrd_list_new();
rrrd_add_filename_arg(self, &arguments);
// RRA index
if (RTEST(index)) {
index = rb_fix2str(index, 10);
rrrd_add_arg(&arguments, "--rraindex");
rrrd_add_arg(&arguments, STR2CSTR(index));
}
time_t first = rrd_first(arguments.length, arguments.strings);
rrrd_free_arguments(arguments);
rrrd_check_for_errors();
return rb_time_new(first, 0);
}
开发者ID:tylerhunt,项目名称:rrrd,代码行数:21,代码来源:rrrd.c
示例20: typecast_timestamp
static VALUE typecast_timestamp(const char *data, uint64_t len) {
struct tm tm;
int64_t epoch, adjust, offset;
char tzsign = 0;
int tzhour = 0, tzmin = 0;
long double sec_fraction = 0;
memset(&tm, 0, sizeof(struct tm));
if (strchr(data, '.')) {
sscanf(data, "%04d-%02d-%02d %02d:%02d:%02d%Lf%c%02d:%02d",
&tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &sec_fraction,
&tzsign, &tzhour, &tzmin);
}
else {
sscanf(data, "%04d-%02d-%02d %02d:%02d:%02d%c%02d:%02d",
&tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec,
&tzsign, &tzhour, &tzmin);
}
tm.tm_year -= 1900;
tm.tm_mon -= 1;
tm.tm_isdst = -1;
if (tm.tm_mday > 0) {
epoch = mktime(&tm);
adjust = client_tzoffset(epoch, tm.tm_isdst);
offset = adjust;
if (tzsign) {
offset = tzsign == '+'
? (time_t)tzhour * 3600 + (time_t)tzmin * 60
: (time_t)tzhour * -3600 + (time_t)tzmin * -60;
}
return rb_time_new(epoch+adjust-offset, (uint64_t)(sec_fraction*1000000L));
}
return rb_str_new(data, len);
}
开发者ID:deepfryed,项目名称:pg_typecast,代码行数:39,代码来源:pg_typecast.c
注:本文中的rb_time_new函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论