Ejemplo n.º 1
0
struct tm *localtime(const time_t *tp) {
  int dayno;
  struct tm *ct;
  int daylbegin, daylend;
  long copyt;
  struct timeb systime;

  ftime(&systime);
  copyt = *tp - (long) systime.timezone * 60;
  ct = gmtime(&copyt);
  dayno = ct->tm_yday;
  daylbegin = 119;	/* last Sun in Apr */
  daylend = 303;	/* Last Sun in Oct */
  if (ct->tm_year == 74 || ct->tm_year == 75) {
    daylbegin = daytab[ct->tm_year - 74].daylb;
    daylend = daytab[ct->tm_year - 74].dayle;
  }
  daylbegin = sunday(ct, daylbegin);
  daylend = sunday(ct, daylend);
  if (systime.dstflag &&
      (dayno > daylbegin || (dayno == daylbegin && ct->tm_hour >= 2)) &&
      (dayno < daylend || (dayno == daylend && ct->tm_hour < 1))) {
    copyt += 1 * 60 * 60;
    ct = gmtime(&copyt);
    ct->tm_isdst++;
  }
  return ct;
}
Ejemplo n.º 2
0
inline void export_templates(){
    sizeof( boost::posix_time::time_period );
    sizeof( boost::gregorian::date_period );
    sizeof( boost::gregorian::weeks );
    sizeof( boost::posix_time::milliseconds );
    sizeof( boost::posix_time::microseconds );
    //In order to get nanoseconds boost::date_time should be compiled with BOOST_DATE_TIME_HAS_NANOSECONDS
    //sizeof( boost::posix_time::nanoseconds );
    sizeof( boost::gregorian::day_clock );
    sizeof( boost::gregorian::gregorian_calendar::day_of_year_type(1) ); 
    sizeof( boost::gregorian::greg_weekday_rep(1) ); 
    sizeof( boost::gregorian::greg_day_rep(1) ); 
    sizeof( boost::gregorian::greg_month_rep(1) ); 
    sizeof( boost::gregorian::greg_year_rep(1) ); 
    sizeof( boost::date_time::year_based_generator<boost::gregorian::date> );
    sizeof( boost::date_time::partial_date<boost::gregorian::date> );
    sizeof( boost::date_time::nth_kday_of_month<boost::gregorian::date> );
    sizeof( boost::date_time::first_kday_of_month<boost::gregorian::date> );
    sizeof( boost::date_time::last_kday_of_month<boost::gregorian::date> );
    sizeof( boost::date_time::first_kday_after<boost::gregorian::date> );
    sizeof( boost::date_time::first_kday_before<boost::gregorian::date> );
    sizeof( boost::date_time::time_zone_names_base<char> );
    
    //exporting 4 functions
    boost::gregorian::date sunday(2003, boost::date_time::Feb,2);
    boost::gregorian::greg_weekday sat(boost::date_time::Saturday);
    boost::gregorian::days_until_weekday(sunday, sat);
    boost::gregorian::days_before_weekday(sunday, sat);
    boost::gregorian::next_weekday(sunday, sat);
    boost::gregorian::previous_weekday(sunday, sat);
    //exporting static function
    boost::date_time::int_adapter<int>::from_special( boost::date_time::not_a_date_time );
    boost::date_time::int_adapter<long int>::from_special( boost::date_time::not_a_date_time );
    boost::date_time::int_adapter<long unsigned int>::from_special( boost::date_time::not_a_date_time );
    
    sizeof( boost::local_time::first_last_dst_rule );
    sizeof( boost::local_time::last_last_dst_rule );
    sizeof( boost::local_time::nth_day_of_the_week_in_month_dst_rule );
    sizeof( boost::local_time::posix_time_zone );
    sizeof( boost::local_time::tz_database );
    sizeof( boost::local_time::partial_date_dst_rule );
    sizeof( boost::local_time::nth_last_dst_rule );
    sizeof( boost::local_time::nth_day_of_the_week_in_month_dst_rule );
    sizeof( boost::local_time::local_time_period );
    sizeof( boost::local_time::local_sec_clock );
    sizeof( boost::local_time::local_microsec_clock );

    sizeof( boost::posix_time::second_clock );
    sizeof( boost::posix_time::microsec_clock );
    sizeof( boost::posix_time::no_dst );
    sizeof( boost::posix_time::us_dst );

}
Ejemplo n.º 3
0
static void
klocaltime(long tim, Tm *ct)
{
	int daylbegin, daylend, dayno, i;
	long copyt;

	copyt = tim - timezone.minuteswest*60L;
	kgmtime(copyt, ct);
	dayno = ct->yday;
	for(i=0;; i++)
		if(ct->year >= daytab[i].yrfrom &&
		   ct->year <= daytab[i].yrto) {
			daylbegin = sunday(ct, daytab[i].daylb);
			daylend = sunday(ct, daytab[i].dayle);
			break;
		}
	if(timezone.dsttime &&
	    (dayno>daylbegin || (dayno==daylbegin && ct->hour>=2)) &&
	    (dayno<daylend || (dayno==daylend && ct->hour<1))) {
		copyt += 60L*60L;
		kgmtime(copyt, ct);
	}
}
Ejemplo n.º 4
0
int main(){
	string str1,str2;
	vector<char> v1;
	vector<char> v2;
	while(cin >> str1){
		cin>>str2;
		v1.clear();
		v2.clear();
		for(char &ch:str1)
			v1.push_back(ch);
		for(char &ch:str2)
			v2.push_back(ch);
		sunday(v1,v2);
	}

}
Ejemplo n.º 5
0
bool Alarm::checkDayOfWeek(const QDateTime &dateTime)
{    
    switch (dateTime.date().dayOfWeek()) {
    case Qt::Monday:
        return monday();
    case Qt::Tuesday:
        return tuesday();
    case Qt::Wednesday:
        return wednesday();
    case Qt::Thursday:
        return thursday();
    case Qt::Friday:
        return friday();
    case Qt::Saturday:
        return saturday();
    case Qt::Sunday:
        return sunday();
    default:
        return false;
    }
}
Ejemplo n.º 6
0
extern	long
cnvdate(int mon, int mday, int year, int hour, int min, int sec)
{
    int	t, i;
    int	daylbegin, daylend;
    int	ly_correction;	/* Leap Year Correction */
    int	dl_correction;	/* Daylight Savings Time Correction */
    long	s;
    static int days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

    days[2] = 28;

    /* Verify Input Parameters. */

    /*	Set  year. */

    if( year < 0) {
        return(-1);
    }
    if( year < 100) {
        if (year < 70) year += 2000;
        else year += 1900;
    }
    if (year < 1970) {
        return(-1);
    }
    if( year>2099 ) {
        return(-1);
    }

    if (dysize(year) == 366) {
        leap_year = 1;
        days[2]++;
    } else
        leap_year = 0;
    /*
     * Set ly_correction = number of leap year days from 1/1/1970 to
     * 1/1/year.
     */
    ly_correction =  ((year-1969) / 4);

    /* Check Month */

    if( (mon < 1) || (mon > 12)) {
        return(-1);
    }

    /* Check Day */

    if ( (mday < 1) || (mday > days[mon]) ) {
        return(-1);
    }

    /* Check Time */

    if( (hour<0) || (hour>23)) {
        return(-1);
    }
    if( (min<0) || (min>59)) {
        return(-1);
    }
    if( (sec<0) || (sec>59)) {
        return(-1);
    }

    /* Calculate Correction for Daylight Savings Time (U.S.) */

    dayno = mday-1;
    for (t=0; t<mon;)
        dayno += days[t++];
    s = (year-1970)*365L + ly_correction + dayno;
    day_of_week = (s + 4) % 7;

    i = 0;
    while (year < daytab[i].yrbgn) {
        /* fall through when in correct interval */
        i++;
        if (i>DAYTABSIZE)
            return(-1);
    }
    daylbegin = daytab[i].daylb;
    daylend = daytab[i].dayle;

    daylbegin = sunday(daylbegin);
    daylend = sunday(daylend);
    if(daylight &&
            (dayno>daylbegin || (dayno==daylbegin && hour>=2)) &&
            (dayno<daylend || (dayno==daylend && hour<1)))
        dl_correction = -1*60*60;
    else
        dl_correction = 0;

    /* Calculate seconds since 00:00:00 1/1/1970. */

    s = ( ( s*24 +hour)*60 +min)*60 + sec + dl_correction;
    return(s+timezone);
}
Ejemplo n.º 7
0
int main()
{
    printf("%d\n", sunday("ababacab", "ababacab"));
}