Преобразуйте “текущее время” во “время в минутах с 0:00” справка вычисления

Если Вы - пользователь свободного выпуска Visual Studio Express, правильный ключ находится в

HKEY_CURRENT_USER\Software\Microsoft\VCExpress\9.0\Text Editor

{отмечают VCExpress вместо VisualStudio), но это работает!:)

5
задан runmad 30 November 2009 в 03:46
поделиться

2 ответа

Я рекомендую использовать объект NSDate для хранения времени закрытия магазина вместо использования вашего собственного целочисленного формата. Очень жаль, что NSDate представляет и дату, и время.

В любом случае вы можете проверить NSDateComponents . У вас может быть такой метод утилит:

int minutesSinceMidnight:(NSDate *)date
{
    NSCalendar *gregorian = [[NSCalendar alloc]
        initWithCalendarIdentifier:NSGregorianCalendar];
    unsigned unitFlags =  NSHourCalendarUnit | NSMinuteCalendarUnit;
    NSDateComponents *components = [gregorian components:unitFlags fromDate:date];

    return 60 * [components hour] + [components minute];    
}
7
ответ дан 13 December 2019 в 19:28
поделиться

If you have another NSDate which is set to midnight, then you can use the timeIntervalSinceDate method of the NSDate object to get an NSTimeInterval back with the difference between the two. Alternatively, if you're always wanting to compare midnight with the current time, you could call the timeIntervalSinceNow method on the midnight NSDate and you'd get an NSTimeInterval back (albeit negative) with the difference between midnight and the current time.

NSTimeInterval is defined as a double by the standard which holds a number of seconds (and any fractional seconds).

1
ответ дан 13 December 2019 в 19:28
поделиться