Ejemplo n.º 1
0
CODATIME_BEGIN

int64_t BaseChronology::getDateTimeMillis(int yearNum, int monthOfYearNum, int dayOfMonthNum,
                          int millisOfDayNum) {
    int64_t instant = year()->set(0, yearNum);
    instant = monthOfYear()->set(instant, monthOfYearNum);
    instant = dayOfMonth()->set(instant, dayOfMonthNum);
    return millisOfDay()->set(instant, millisOfDayNum);
}
Ejemplo n.º 2
0
/** Gets all days in the month on which this rule is repeated.

@param aDays On return this array contains all days in the month that are to be set. 
This function will do nothing if this is not a monthly or yearly repeat rule. 
@publishedAll
@released 
@capability None
*/
EXPORT_C void TCalRRule::GetByDayL(RArray<TDayOfMonth>& aDays) const
	{
	if (iType == EMonthly)
		{
		aDays.Reset();
		if (GetNthBit(KMonthlyByWeek))
			{
			// if i == 35, then weekNum = 5 below which is too high
			for (TUint i = 0; i < 35; ++i)
				{
				if (GetNthBit(i))
					{
					// This is the reverse of the algorithm in TCalRRule::SetByDay(const RArray<TDayOfMonth>& aDays)
					TDay day = static_cast<TDay>(i % 7);
					TInt weekNum = i / 7;
					if (weekNum == 0)
						{
						weekNum = -1;
						}
					TDayOfMonth dayOfMonth(day, weekNum);
					aDays.AppendL(dayOfMonth);
					}
				}
			}
		}
	else if (iType == EYearly)
		{
		aDays.Reset();
		if (GetNthBit(KYearlyByWeek))
			{
			TUint8* bufferPtr = (TUint8*)&iBuffer; // convert the iBuffer store to three TUint8s
			TDay theDay = TDay(bufferPtr[0]-1); // -1 because EMonday is stored as +1
			TInt8 theWeek = TInt8(bufferPtr[1]);
			
			if (theDay >= EMonday && theDay <= ESunday)
				{
				TDayOfMonth dayOfMonth(theDay, theWeek);
				aDays.AppendL(dayOfMonth);
				}
			}
		}
	}
Ejemplo n.º 3
0
int64_t BaseChronology::getDateTimeMillis(int yearNum, int monthOfYearNum, int dayOfMonthNum,
                          int hourOfDayNum, int minuteOfHourNum,
                          int secondOfMinuteNum, int millisOfSecondNum) {
    int64_t instant = year()->set(0, yearNum);
    instant = monthOfYear()->set(instant, monthOfYearNum);
    instant = dayOfMonth()->set(instant, dayOfMonthNum);
    instant = hourOfDay()->set(instant, hourOfDayNum);
    instant = minuteOfHour()->set(instant, minuteOfHourNum);
    instant = secondOfMinute()->set(instant, secondOfMinuteNum);
    return millisOfSecond()->set(instant, millisOfSecondNum);
}
Ejemplo n.º 4
0
int
monthOfWeek(time_t t, bool beginOnMonday)
{
    const struct tm* tms = clocaltime(&t);
    int tm_mon = tms->tm_mon;
    int tm_mday = tms->tm_mday;
    int lastDayOfMonth = dayOfMonth(beginOfMonth(sameTimeNextMonth(t)) - 1);
    if (tm_mday < 4)
    {
        if (dayOfWeek(t, beginOnMonday) - tm_mday >= 3)
	{
            if (tm_mon == 0)
	    {
                return 12;
	    }
            else
	    {
                return tm_mon;
	    }
	}
    }
    else if (tm_mday > lastDayOfMonth - 4)
    {
        if (tm_mday - dayOfWeek(t, beginOnMonday) > lastDayOfMonth - 4)
	{
            if (tm_mon == 11)
	    {
                return 1;
	    }
            else
	    {
                return tm_mon + 2;
	    }
	}
    }
    return tm_mon + 1;
}
Ejemplo n.º 5
0
QDate
time2qdate(time_t t)
{
    return QDate(year(t), monthOfYear(t), dayOfMonth(t));
}