void buildURLYahoo(const axutil_env_t* env,axis2_char_t* symbol,axutil_date_time_t* start, axutil_date_time_t* end,ostringstream& oss)
{
	int syear = axutil_date_time_get_year(start,env);
	int smonth = axutil_date_time_get_month(start,env);
	int sdate = axutil_date_time_get_date(start,env);
	int eyear = axutil_date_time_get_year(end,env);
	int emonth = axutil_date_time_get_month(end,env);
	int edate = axutil_date_time_get_date(end,env);
	oss.str("");
	oss<<"http://ichart.finance.yahoo.com/table.csv?s="<<symbol;
	oss<<"&a="<<(smonth-1)<<"&b="<<sdate<<"&c="<<syear;
	oss<<"&d="<<(emonth-1)<<"&e="<<edate<<"&f="<<eyear;
	oss<<"&g=w&ingore=.csv";

}
void buildURLGoogle(const axutil_env_t* env,axis2_char_t* symbol,axutil_date_time_t* start, axutil_date_time_t* end,ostringstream& oss)
{
	int syear = axutil_date_time_get_year(start,env);
	int smonth = axutil_date_time_get_month(start,env);
	int sdate = axutil_date_time_get_date(start,env);
	int eyear = axutil_date_time_get_year(end,env);
	int emonth = axutil_date_time_get_month(end,env);
	int edate = axutil_date_time_get_date(end,env);
	oss.str("");
	oss<<"http://www.google.com/finance/historical?q=";
	oss<<symbol<<"&startdate=";
	oss<<GlobalVariables::m_months[smonth]<<"+"<<sdate<<"%2C+"<<syear<<"&enddate=";
	oss<<GlobalVariables::m_months[emonth]<<"+"<<edate<<"%2C+"<<eyear<<"&histperiod=weekly&num=30&output=csv";
	AXIS2_LOG_INFO(env->log,"build url google version [%s]",oss.str().c_str());
}
static int datetime_to_unix (axutil_date_time_t *dt, axutil_env_t *env)
{
    time_t tsu, ts, tsdelta, tsdelta_min;
    struct tm *tmu;
    
    ts = time(NULL);
    tmu = gmtime(&ts);
    tsu = mktime(tmu);
    tsdelta = (tsu - ts) / 3600;
    tsdelta_min = ((tsu - ts) - (tsdelta * 3600)) / 60;
    
    struct tm t = {
        axutil_date_time_get_second(dt, env),
        axutil_date_time_get_minute(dt, env) - tsdelta_min,
        axutil_date_time_get_hour(dt, env) - tsdelta,
        axutil_date_time_get_date(dt, env),
        axutil_date_time_get_month(dt, env)-1,
        axutil_date_time_get_year(dt, env)-1900,
        0,
        0,
        0
    };
    
    return (int) mktime(&t);
}
Ejemplo n.º 4
0
AXIS2_EXTERN unsigned int AXIS2_CALL
axutil_rand_get_seed_value_based_on_time(
    const axutil_env_t * env)
{
    axutil_date_time_t *date = axutil_date_time_create(env);
    unsigned int rand_var = axutil_date_time_get_year(date, env);
    rand_var += axutil_date_time_get_month(date, env);
    rand_var += axutil_date_time_get_date(date, env);
    rand_var += axutil_date_time_get_hour(date, env);
    rand_var += axutil_date_time_get_minute(date, env);
    rand_var += axutil_date_time_get_second(date, env);
    axutil_date_time_free(date, env);
    return rand_var;
}