Example #1
0
RSPrivate RSTimeInterval __RSTimeIntervalUntilTSR(uint64_t tsr) {
    RSDateGetTypeID();
    uint64_t now = mach_absolute_time();
    if (tsr >= now) {
        return __RSTSRToTimeInterval(tsr - now);
    } else {
        return -__RSTSRToTimeInterval(now - tsr);
    }
}
Example #2
0
RSExport void RSCalendarSetGregorianStartDate(RSCalendarRef calendar, RSDateRef date) {
    RS_OBJC_FUNCDISPATCHV(RSCalendarGetTypeID(), void, calendar, _setGregorianStartDate:date);
    __RSGenericValidInstance(calendar, RSCalendarGetTypeID());
    if (date) __RSGenericValidInstance(date, RSDateGetTypeID());
    if (!calendar->_cal) __RSCalendarSetupCal(calendar);
    if (!calendar->_cal) return;
    if (!date) {
        UErrorCode status = U_ZERO_ERROR;
        UCalendar *cal = __RSCalendarCreateUCalendar(calendar->_identifier, calendar->_tz);
        UDate udate = cal ? ucal_getGregorianChange(cal, &status) : 0;
        if (cal && U_SUCCESS(status)) {
            status = U_ZERO_ERROR;
            if (calendar->_cal) ucal_setGregorianChange(calendar->_cal, udate, &status);
        }
        if (cal) ucal_close(cal);
    } else {
        RSAbsoluteTime at = RSDateGetAbsoluteTime(date);
        UDate udate = (at + RSAbsoluteTimeIntervalSince1970) * 1000.0;
        UErrorCode status = U_ZERO_ERROR;
        if (calendar->_cal) ucal_setGregorianChange(calendar->_cal, udate, &status);
    }
}
Example #3
0
static   RSDateRef __RSDateCreateInstance(RSAllocatorRef allocator, RSAbsoluteTime time)
{
    RSDateRef date = (RSDateRef)__RSRuntimeCreateInstance(allocator, RSDateGetTypeID(), sizeof(struct __RSDate) - sizeof(struct __RSRuntimeBase));
    ((struct __RSDate*)date)->_time = time;
    return date;
}
Example #4
0
static  void __RSDateAvailable(RSDateRef date)
{
    if (date == nil) HALTWithError(RSInvalidArgumentException, "date is nil");
    if (RSGetTypeID(date) != RSDateGetTypeID()) HALTWithError(RSInvalidArgumentException, "date is not kind of RSDate");
    return;
}