Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9092597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:52:46+00:00 2026-06-16T22:52:46+00:00

I am trying to find out if the recent Do Not Disturb bug (

  • 0

I am trying to find out if the recent Do Not Disturb bug (Ars Technica link) is affecting my code. I am trying to get the date and timestamp for midnight the previous Monday. Since I am writing this on a Monday, I would expect to get today’s date (January 7, 2013), yet I am January 4, 2013.

I am following the guide posted by Apple, but I am trying to modify it to find the previous Monday, instead of Sunday.

+(NSTimeInterval)StartOfWeekMonday {
    NSTimeInterval finalTime = -1;

    NSInteger weekday;

    NSDate *monday  = 0;

    NSCalendar *greg = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

    NSDateComponents *weekdays = [greg components:NSWeekdayCalendarUnit fromDate:[NSDate date]];
    NSDateComponents *subtract = [[NSDateComponents alloc] init];
    NSDateComponents *final    = 0;

    weekday = ( weekdays.weekday == 1 ) ? 6 : weekdays.weekday;

    [subtract setDay:(0 - weekday - 1)];

    monday = [greg dateByAddingComponents:subtract toDate:[NSDate date] options:0];
    final  = [greg components:(NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit) fromDate:monday];
    monday = [greg dateFromComponents:final];

#ifdef DEBUG
    NSLog( @"%s - %d -> Weekday: %d", __FILE__, __LINE__, weekday );
    NSLog( @"%s - %d -> Monday: %@", __FILE__, __LINE__, [monday descriptionWithLocale:[NSLocale currentLocale]] );
#endif

    finalTime = [monday timeIntervalSince1970];


    return finalTime;
}

My log out put below, the weekday is correct (I am writing this on a Monday), yet the date is obviously wrong, it should be Monday: Monday, January 7, 2013, 12:00 AM

2013-01-07 15:07:33.792 MY-APP[5524:14c03] Weekday: 2
2013-01-07 15:07:36.757 MY-APP[5524:14c03] Monday: Friday, January 4, 2013, 12:00:00 AM Eastern Standard Time

This is being in the simulator right now, but all my other date calculations are giving the expected values.

Is it likely that I am being affected by the recent Do Not Disturb Bug and will have to wait for tomorrow (January 8, 2013) to see the expected results, or am I missing something entirely different?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T22:52:48+00:00Added an answer on June 16, 2026 at 10:52 pm

    The issue was with how to calculate the subtraction. Either I completely mis understood the example provided by Apple, or it was not clear enough. The solution for calculating the subtraction was as follows:

    weekday = ( weekdays.weekday == 1 ) ? 8 : weekdays.weekday;
    toSubtract = ( 2 - weekday );
    
    [subtract setDay:toSubtract];
    

    Running various tests produced the proper “Monday.” In the end, this had nothing to do with the date bug affecting Do Not Disturb.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i m trying to find out how to convert timestamp date and time (
I am trying to find out if an instance of an application (not vb.net)
Trying to find out if it's possible to use SQLAlchemy on Heroku. Thanks.
I trying to find out the visibility of the Excel and do some activities
I am trying to find out how to write an SQL statement that will
I am trying to find out a way to set a time tag to
I'm trying to find out how to change the icon of a JStree node
I'm trying to find out a little bit more about how the preprocessor works
I am trying to find out which edges from a graph are bidirectional. Each
I am just trying to find out that does puppet have something similar to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.