当前位置: 首页>>代码示例>>C++>>正文


C++ parse_date函数代码示例

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


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


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