• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ parse_date函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中parse_date函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_date函数的具体用法?C++ parse_date怎么用?C++ parse_date使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了parse_date函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: parse_date

 date_type
 parse_date(const string_type& value, 
            const string_type& format) const
 {
   stringstream_type ss;
   ss << value; 
   stream_itr_type sitr(ss);
   stream_itr_type stream_end;
   return parse_date(sitr, stream_end, format);
 }
开发者ID:dmm,项目名称:cegis,代码行数:10,代码来源:format_date_parser.hpp


示例2: parse_time_or_die

int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration)
{
    int64_t us = parse_date(timestr, is_duration);
    if (us == INT64_MIN) {
        fprintf(stderr, "Invalid %s specification for %s: %s\n",
                is_duration ? "duration" : "date", context, timestr);
        exit(1);
    }
    return us;
}
开发者ID:TheWorldCodeCopierAssociation,项目名称:TakePics,代码行数:10,代码来源:cmdutils.c


示例3: vi_is_weekend

/* returns 1 if the given date is Saturday or Sunday.
 * Zero is otherwise returned. */
int vi_is_weekend(char *s, int time_delta)
{
  struct tm tm;

  if (parse_date(s, &tm, time_delta) != (time_t)-1) {
    if (tm.tm_wday == 0 || tm.tm_wday == 6)
      return 1;
  }
  return 0;
}
开发者ID:benzid-wael,项目名称:xvisitors,代码行数:12,代码来源:date_utils.c


示例4: x

void rss_parser::fill_feed_items(std::tr1::shared_ptr<rss_feed> feed) {
	/*
	 * we iterate over all items of a feed, create an rss_item object for
	 * each item, and fill it with the appropriate values from the data structure.
	 */
	for (std::vector<rsspp::item>::iterator item=f.items.begin();item!=f.items.end();item++) {
		std::tr1::shared_ptr<rss_item> x(new rss_item(ch));

		set_item_title(feed, x, *item);

		if (item->link != "") {
			x->set_link(utils::absolute_url(feed->link(), item->link));
		}

		set_item_author(x, *item);

		x->set_feedurl(feed->rssurl());

		if (f.rss_version == rsspp::ATOM_1_0 && item->labels.size() > 0) {
			std::vector<std::string>::const_iterator start, finish;
			start = item->labels.begin();
			finish = item->labels.end();
			if (std::find(start, finish, "fresh") != finish) {
				x->set_unread_nowrite(true);
				x->set_override_unread(true);
			} 
			if (std::find(start, finish, "kept-unread") != finish) {
				x->set_unread_nowrite(true);
				x->set_override_unread(true);
			}
			if (std::find(start, finish, "read") != finish) {
				x->set_unread_nowrite(false);
				x->set_override_unread(true);
			}
		}

		set_item_content(x, *item);

		if (item->pubDate != "") 
			x->set_pubDate(parse_date(item->pubDate));
		else
			x->set_pubDate(::time(NULL));
			
		x->set_guid(get_guid(*item));

		x->set_base(item->base);

		set_item_enclosure(x, *item);

		LOG(LOG_DEBUG, "rss_parser::parse: item title = `%s' link = `%s' pubDate = `%s' (%d) description = `%s'", x->title().c_str(), 
			x->link().c_str(), x->pubDate().c_str(), x->pubDate_timestamp(), x->description().c_str());

		add_item_to_feed(feed, x);
	}
}
开发者ID:cybersiddhu,项目名称:newsbeuter,代码行数:55,代码来源:rss_parser.cpp


示例5: command_insert

int8_t command_insert( uint8_t *pszCommandString, tUserState *pState )
{
    int32_t iRetVal;
    tDateTime tempDate;
    char szFirstName[MAX_STRING_LENGTH+1];
    char szLastName[MAX_STRING_LENGTH+1];
    char szUserName[MAX_STRING_LENGTH+1];
    char szTemp[MAX_STRING_LENGTH+1];
    uint32_t creationDate;
    uint32_t newRecordNumber;

    printf( "First name: " );

    iRetVal = readLine( STDIN, szFirstName, MAX_STRING_LENGTH );

    sanitize_string( szFirstName );

    printf( "Last name: " );

    iRetVal = readLine( STDIN, szLastName, MAX_STRING_LENGTH );

    sanitize_string( szLastName );

    printf( "User name: " );

    iRetVal = readLine( STDIN, szUserName, MAX_STRING_LENGTH );

    sanitize_string( szUserName );

    printf( "Birthdate (mm/dd/yy hh:mm:ss): " );

    iRetVal = readLine( STDIN, szTemp, MAX_STRING_LENGTH );

    creationDate = parse_date( szTemp, &tempDate );

    if ( creationDate == 0 )
    {
        printf( "Date parsing error.\n" );
        return 0;
    }

    printf( "Date is: $d/$d/$d $d:$d:$d\n", tempDate.month, tempDate.day, GET_DB_YEAR(tempDate.year), tempDate.hour, tempDate.minute, tempDate.second );

    // Insert into database
    newRecordNumber = db_add_record( szUserName, szFirstName, szLastName, tempDate );

    if ( newRecordNumber == BAD_RECORD_ERROR )
    {
        printf( "Database full.\n" );
        return 0;
    }

    printf( "Data added, record $d\n", newRecordNumber );
    return 0;
}
开发者ID:CyberGrandChallenge,项目名称:samples,代码行数:55,代码来源:command_handler.c


示例6: typecast

static VALUE typecast(VALUE r_value, const VALUE type) {
  VALUE r_data;

  if (type == rb_cInteger) {
    return TYPE(r_value) == T_FIXNUM || TYPE(r_value) == T_BIGNUM ? r_value : rb_funcall(r_value, DO_ID_TO_I, 0);

  } else if (type == rb_cString) {
    if (TYPE(r_value) == T_STRING)
      return r_value;
    else if (rb_obj_class(r_value) == cOCI8_CLOB)
      return rb_funcall(r_value, DO_ID_READ, 0);
    else
      return rb_funcall(r_value, DO_ID_TO_S, 0);

  } else if (type == rb_cFloat) {
    return TYPE(r_value) == T_FLOAT ? r_value : rb_funcall(r_value, DO_ID_TO_F, 0);

  } else if (type == rb_cBigDecimal) {
    VALUE r_string = TYPE(r_value) == T_STRING ? r_value : rb_funcall(r_value, DO_ID_TO_S, 0);
    return rb_funcall(rb_cBigDecimal, DO_ID_NEW, 1, r_string);

  } else if (type == rb_cDate) {
    return parse_date(r_value);

  } else if (type == rb_cDateTime) {
    return parse_date_time(r_value);

  } else if (type == rb_cTime) {
    return parse_time(r_value);

  } else if (type == rb_cTrueClass) {
    return parse_boolean(r_value);

  } else if (type == rb_cByteArray) {
    if (rb_obj_class(r_value) == cOCI8_BLOB)
      r_data = rb_funcall(r_value, DO_ID_READ, 0);
    else
      r_data = r_value;
    return rb_funcall(rb_cByteArray, DO_ID_NEW, 1, r_data);

  } else if (type == rb_cClass) {
    return rb_funcall(mDO, DO_ID_FULL_CONST_GET, 1, r_value);

  } else if (type == rb_cNilClass) {
    return Qnil;

  } else {
    if (rb_obj_class(r_value) == cOCI8_CLOB)
      return rb_funcall(r_value, DO_ID_READ, 0);
    else
      return r_value;
  }

}
开发者ID:datamapper,项目名称:do,代码行数:54,代码来源:do_oracle.c


示例7: typecast

static VALUE typecast(sqlite3_stmt *stmt, int i, VALUE ruby_class) {
  const char *ruby_type;
  VALUE ruby_value = Qnil;
  int original_type = sqlite3_column_type(stmt, i);
  int length        = sqlite3_column_bytes(stmt, i);
  if ( original_type == SQLITE_NULL ) {
    return ruby_value;
  }

  if ( original_type == SQLITE_BLOB ) {
    return TAINTED_STRING((char*)sqlite3_column_blob(stmt, i), length);
  }

  if(ruby_class == Qnil) {
    switch(original_type) {
      case SQLITE_INTEGER: {
        ruby_type = "Integer";
        break;
      }
      case SQLITE_FLOAT: {
        ruby_type = "Float";
        break;
      }
      default: {
        ruby_type = "String";
        break;
      }
    }
  } else {
    ruby_type = rb_class2name(ruby_class);
  }

  if ( strcmp(ruby_type, "Class") == 0) {
    return rb_funcall(rb_cObject, rb_intern("full_const_get"), 1, TAINTED_STRING((char*)sqlite3_column_text(stmt, i), length));
  } else if ( strcmp(ruby_type, "Object") == 0 ) {
    return rb_marshal_load(rb_str_new2((char*)sqlite3_column_text(stmt, i)));
  } else if ( strcmp(ruby_type, "TrueClass") == 0 ) {
    return strcmp((char*)sqlite3_column_text(stmt, i), "t") == 0 ? Qtrue : Qfalse;
  } else if ( strcmp(ruby_type, "Integer") == 0 || strcmp(ruby_type, "Fixnum") == 0 || strcmp(ruby_type, "Bignum") == 0 ) {
    return LL2NUM(sqlite3_column_int64(stmt, i));
  } else if ( strcmp(ruby_type, "BigDecimal") == 0 ) {
    return rb_funcall(rb_cBigDecimal, ID_NEW, 1, TAINTED_STRING((char*)sqlite3_column_text(stmt, i), length));
  } else if ( strcmp(ruby_type, "Float") == 0 ) {
    return rb_float_new(sqlite3_column_double(stmt, i));
  } else if ( strcmp(ruby_type, "Date") == 0 ) {
    return parse_date((char*)sqlite3_column_text(stmt, i));
  } else if ( strcmp(ruby_type, "DateTime") == 0 ) {
    return parse_date_time((char*)sqlite3_column_text(stmt, i));
  } else if ( strcmp(ruby_type, "Time") == 0 ) {
    return parse_time((char*)sqlite3_column_text(stmt, i));
  } else {
    return TAINTED_STRING((char*)sqlite3_column_text(stmt, i), length);
  }
}
开发者ID:Bluejade,项目名称:rots_consumer,代码行数:54,代码来源:do_sqlite3_ext.c


示例8: setup_ident

const char *fmt_ident(const char *name, const char *email,
		      const char *date_str, int flag)
{
	static char buffer[1000];
	char date[50];
	int i;
	int error_on_no_name = (flag & IDENT_ERROR_ON_NO_NAME);
	int warn_on_no_name = (flag & IDENT_WARN_ON_NO_NAME);
	int name_addr_only = (flag & IDENT_NO_DATE);

	setup_ident();
	if (!name)
		name = git_default_name;
	if (!email)
		email = git_default_email;

	if (!*name) {
		struct passwd *pw;

		if ((warn_on_no_name || error_on_no_name) &&
		    name == git_default_name && env_hint) {
			fputs(env_hint, stderr);
			env_hint = NULL; /* warn only once */
		}
		if (error_on_no_name)
			die("empty ident %s <%s> not allowed", name, email);
		pw = getpwuid(getuid());
		if (!pw)
			die("You don't exist. Go away!");
		strlcpy(git_default_name, pw->pw_name,
			sizeof(git_default_name));
		name = git_default_name;
	}

	strcpy(date, git_default_date);
	if (!name_addr_only && date_str && date_str[0]) {
		if (parse_date(date_str, date, sizeof(date)) < 0)
			die("invalid date format: %s", date_str);
	}

	i = copy(buffer, sizeof(buffer), 0, name);
	i = add_raw(buffer, sizeof(buffer), i, " <");
	i = copy(buffer, sizeof(buffer), i, email);
	if (!name_addr_only) {
		i = add_raw(buffer, sizeof(buffer), i,  "> ");
		i = copy(buffer, sizeof(buffer), i, date);
	} else {
		i = add_raw(buffer, sizeof(buffer), i, ">");
	}
	if (i >= sizeof(buffer))
		die("Impossibly long personal identifier");
	buffer[i] = 0;
	return buffer;
}
开发者ID:jeffgarrett,项目名称:git,代码行数:54,代码来源:ident.c


示例9: seconds_from_str

// input is string in the format "DD-MMM-YYYY, hh:mm:ss" (as in parse_date())
// output is seconds since midnight, Jan 1, 1900 (as from date2sec())
double seconds_from_str(const char *date_str)
{
  ymd_date d;
  hms_time t;
  parse_date(date_str, &d, &t);
  t.sec = 0;

  julian_date jd;
  date_ymd2jd(&d, &jd);

  return date2sec(&jd, &t);
}
开发者ID:thisissmithj,项目名称:ASF_MapReady,代码行数:14,代码来源:dateUtil.c


示例10: try_to_open_csv

int try_to_open_csv(struct memblock *mem, enum csv_format type)
{
	char *p = mem->buffer;
	char *header[8];
	int i, time;
	timestamp_t date;
	struct dive *dive;
	struct divecomputer *dc;

	for (i = 0; i < 8; i++) {
		header[i] = p;
		p = strchr(p, ',');
		if (!p)
			return 0;
		p++;
	}

	date = parse_date(header[2]);
	if (!date)
		return 0;

	dive = alloc_dive();
	dive->when = date;
	dive->number = atoi(header[1]);
	dc = &dive->dc;

	time = 0;
	for (;;) {
		char *end;
		double val;
		struct sample *sample;

		errno = 0;
		val = strtod(p, &end); // FIXME == localization issue
		if (end == p)
			break;
		if (errno)
			break;

		sample = prepare_sample(dc);
		sample->time.seconds = time;
		add_sample_data(sample, type, val);
		finish_sample(dc);

		time++;
		dc->duration.seconds = time;
		if (*end != ',')
			break;
		p = end + 1;
	}
	record_dive(dive);
	return 1;
}
开发者ID:glance-,项目名称:subsurface,代码行数:53,代码来源:import-csv.c


示例11: parse_rmc

static void parse_rmc(struct gps_tpv *tpv, const char **token)
{
    if (is_status_valid(token[1][0]))
    {
        parse_time(tpv->time, token[0]);
        tpv->latitude = parse_angular_distance(token[2], token[3][0]);
        tpv->longitude = parse_angular_distance(token[4], token[5][0]);
        tpv->track = parse_track(token[7], 'T');
        tpv->speed = parse_speed(token[6], 'N');
        parse_date(tpv->time, token[8]);
    }
}
开发者ID:JCube001,项目名称:libgps,代码行数:12,代码来源:gps.c


示例12: parse

/* Main parser function
 */
int parse() {
	token = yylex();
	do {
		switch (token) {
		case TITLE:
			if (!parse_title()) return 0;
			break;
		case AUTHOR:
			if (!parse_author()) return 0;
			break;
		case DATE:
			if (!parse_date()) return 0;
			break;
		case SECTION:
			if (!parse_section()) return 0;
			break;
		case FRAME:
			if (!parse_frame()) return 0;
			break;
		case PART:
			if (!parse_part()) return 0;
			break;
		case EOF:
		case ZERO:
			return 1;
		case NEWLINE:
			token = yylex();
			break;
		case IMAGE:
			fprintf(stderr, "[%d] Top mode: figure not allowed in top mode.\n",yylineno);
			return 0;
		case ANIMATION:
			fprintf(stderr, "[%d] Top mode: figure not allowed in top mode.\n",yylineno);
			return 0;
		case LISTING:
			fprintf(stderr, "[%d] Top mode: listing not allowed in top mode.\n", yylineno);
			return 0;
		case STRUCT:
			fprintf(stderr, "[%d] Top mode: structure not allowed in top mode.\n", yylineno);
			return 0;
		case ITEM:
			fprintf(stderr, "[%d] Top mode: item not allowed in top mode.\n", yylineno);
			return 0;
		default:
			fprintf(stderr, "[%d] Top mode: %s \"%s\" not allowed in top mode.\n", yylineno,
					get_token_name(token), yytext);
			return 0;
		}
	} while (token != EOF);

	return 1;
}
开发者ID:rju,项目名称:slp,代码行数:54,代码来源:parser.c


示例13: header_retry_after

void header_retry_after(const char *s)
{
  struct tm tm;

  if (s[0] != 0 && strspn(s, NUMBER) == strlen(s)) {
    lookup("ok");
    return;
  }

  if (!parse_date(s, &tm))
    return;

  lookup("ok");
}
开发者ID:krishnaneeraja,项目名称:PDS_Demo,代码行数:14,代码来源:httplint.c


示例14: parse_date_or_number

int parse_date_or_number(const char* s, int absolute, double *value)
{
    Dates_format dummy;
    const char *sdummy;
    
    if (parse_date(s, get_date_hint(), absolute, value, &dummy)
        == RETURN_SUCCESS) {
        return RETURN_SUCCESS;
    } else if (parse_float(s, value, &sdummy) == RETURN_SUCCESS) {
        return RETURN_SUCCESS;
    } else {
        return RETURN_FAILURE;
    }
}
开发者ID:OS2World,项目名称:APP-ANALYSIS-QtGrace,代码行数:14,代码来源:dates.cpp


示例15: process_done

/*}}}*/
int process_done(char **x)/*{{{*/
{
  time_t done_time = time(NULL);

  if (*x && (x[0][0] == '@')) {
    int error;
    done_time = parse_date(x[0]+1, done_time, 0, &error);
    if (error < 0) return error;
    x++;
  }

  internal_done(done_time, x);
  return 0;
}
开发者ID:T-J-Teru,项目名称:tdl,代码行数:15,代码来源:done.c


示例16: parse_date

void HTTPAndroidRequest::onResponse(int code, std::string message, std::string etag, std::string modified, std::string cacheControl, std::string expires, std::string body) {
    response = std::make_unique<Response>();
    using Error = Response::Error;

    response->modified = parse_date(modified.c_str());
    response->etag = etag;
    response->expires = parseCacheControl(cacheControl.c_str());
    if (!expires.empty()) {
        response->expires = parse_date(expires.c_str());
    }
    response->data = std::make_shared<std::string>(body);

    if (code == 200) {
        // Nothing to do; this is what we want
    } else if (code == 304) {
        if (existingResponse) {
            if (existingResponse->error) {
                response->error = std::make_unique<Error>(*existingResponse->error);
            }
            response->data = existingResponse->data;
            response->modified = existingResponse->modified;
            // We're not updating `expired`, it was probably set during the request.
            response->etag = existingResponse->etag;
        } else {
            // This is an unsolicited 304 response and should only happen on malfunctioning
            // HTTP servers. It likely doesn't include any data, but we don't have much options.
        }
    } else if (code == 404) {
        response->error = std::make_unique<Error>(Error::Reason::NotFound, "HTTP status code 404");
    } else if (code >= 500 && code < 600) {
        response->error = std::make_unique<Error>(Error::Reason::Server, std::string{ "HTTP status code " } + std::to_string(code));
    } else {
        response->error = std::make_unique<Error>(Error::Reason::Other, std::string{ "HTTP status code " } + std::to_string(code));
    }

    async.send();
}
开发者ID:vosst,项目名称:mapbox-gl-native,代码行数:37,代码来源:http_request_android.cpp


示例17: read_agefile

time_t read_agefile(char *path)
{
	FILE *f;
	static char buf[64], buf2[64];

	if (!(f = fopen(path, "r")))
		return -1;
	if (fgets(buf, sizeof(buf), f) == NULL)
		return -1;
	fclose(f);
	if (parse_date(buf, buf2, sizeof(buf2)))
		return strtoul(buf2, NULL, 10);
	else
		return 0;
}
开发者ID:certik,项目名称:cgit,代码行数:15,代码来源:ui-repolist.c


示例18: parse_rfc1123

time_t
parse_rfc1123(const char *str, int len)
{
    struct tm *tm;
    time_t t;
    if (NULL == str)
	return -1;
    tm = parse_date(str, len);
    if (!tm)
	return -1;
    tm->tm_isdst = -1;
#ifdef HAVE_TIMEGM
    t = timegm(tm);
#elif HAVE_TM_GMTOFF
    t = mktime(tm);
    if (t != -1) {
	struct tm *local = localtime(&t);
	t += local->tm_gmtoff;
    }
#else
    /* some systems do not have tm_gmtoff so we fake it */
    t = mktime(tm);
    if (t != -1) {
	time_t dst = 0;
#if defined (_TIMEZONE)
#elif defined (_timezone)
#elif defined(_SQUID_AIX_)
#elif defined(_SQUID_CYGWIN_)
#elif defined(_SQUID_MSWIN_)
#elif defined(_SQUID_SGI_)
#else
	extern long timezone;
#endif
	/*
	 * The following assumes a fixed DST offset of 1 hour,
	 * which is probably wrong.
	 */
	if (tm->tm_isdst > 0)
	    dst = -3600;
#if defined ( _timezone) || defined(_SQUID_WIN32_)
	t -= (_timezone + dst);
#else
	t -= (timezone + dst);
#endif
    }
#endif
    return t;
}
开发者ID:arthurtumanyan,项目名称:squid-2.6-stable13-shaga,代码行数:48,代码来源:rfc1123.c


示例19: parse_dates

static void parse_dates(char **argv, struct timeval *now)
{
	for (; *argv; argv++) {
		char result[100];
		unsigned long t;
		int tz;

		result[0] = 0;
		parse_date(*argv, result, sizeof(result));
		if (sscanf(result, "%lu %d", &t, &tz) == 2)
			printf("%s -> %s\n",
			       *argv, show_date(t, tz, DATE_ISO8601));
		else
			printf("%s -> bad\n", *argv);
	}
}
开发者ID:777,项目名称:test-proj,代码行数:16,代码来源:test-date.c


示例20: crm_time_new

crm_time_t *
crm_time_new(const char *date_time)
{
    time_t tm_now;
    crm_time_t *dt = NULL;

    tzset();
    if (date_time == NULL) {
        tm_now = time(NULL);
        dt = calloc(1, sizeof(crm_time_t));
        crm_time_set_timet(dt, &tm_now);
    } else {
        dt = parse_date(date_time);
    }
    return dt;
}
开发者ID:beess,项目名称:pacemaker,代码行数:16,代码来源:iso8601.c



注:本文中的parse_date函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ parse_double函数代码示例发布时间:2022-05-30
下一篇:
C++ parse_data函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap