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 8588155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:44:31+00:00 2026-06-11T22:44:31+00:00

The same code NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@d MMMM yyyy GG];

  • 0

The same code

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"d MMMM yyyy GG"];
//13th of December 1577
NSDate * aDate = [NSDate dateWithTimeIntervalSince1970:-12371067248]; 

NSString * formattedDate = [dateFormatter stringFromDate:aDate];

Mac OS X target shows formattedDate correctly

13th of December 1577

iOS 5.0 target shows

23rd of December 1577

as if the Julian -> Gregorian transition was bugged

Any ideas how to overcome that?

  • 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-11T22:44:32+00:00Added an answer on June 11, 2026 at 10:44 pm

    Try running this code on both Mac and iOS

    NSDateFormatter *localFormatter = [[NSDateFormatter alloc] init];
    localFormatter.timeStyle = NSDateFormatterNoStyle;
    localFormatter.dateStyle = NSDateFormatterMediumStyle;
    
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"g"];  // g = julian day number
    NSDate *d2299159 = [dateFormatter dateFromString:@"2299159"];
    NSDate *d2299160 = [dateFormatter dateFromString:@"2299160"];
    NSDate *d2299161 = [dateFormatter dateFromString:@"2299161"];
    NSDate *d2299162 = [dateFormatter dateFromString:@"2299162"];
    
    
    NSLog(@"Julian Day Number 2299159 = %@", [localFormatter stringFromDate:d2299159]);
    NSLog(@"Julian Day Number 2299160 = %@", [localFormatter stringFromDate:d2299160]);
    NSLog(@"Julian Day Number 2299161 = %@", [localFormatter stringFromDate:d2299161]);
    NSLog(@"Julian Day Number 2299162 = %@", [localFormatter stringFromDate:d2299162]);
    

    and you wil get these outputs (except the <– notes):

    Mac

    Julian Day Number 2299159 = 1582-10-03   <-- Julian calendar
    Julian Day Number 2299160 = 1582-10-04   <-- Julian calendar
    Julian Day Number 2299161 = 1582-10-15   <-- Gregorian calendar
    Julian Day Number 2299162 = 1582-10-16   <-- Gregorian calendar
    

    iOS

    Julian Day Number 2299159 = 1582-10-13   <-- Proleptic Gregorian calendar
    Julian Day Number 2299160 = 1582-10-14   <-- Proleptic Gregorian calendar
    Julian Day Number 2299161 = 1582-10-15   <-- Gregorian calendar
    Julian Day Number 2299162 = 1582-10-16   <-- Gregorian calendar
    

    On the Mac NSDateFormatter switches to the Julian calendar (also called old style dates) for dates preceding Oct 15, 1582 which is the first day in the Gregorian calendar (that Apple works with. Some countries adopted on different dates).
    If you refer to Gregorian dates before this date, these dates are in the proleptic Gregorian calendar, meaning, dates before the Gregorian existed. And, as you can see from the second output NSDateFormatter on the iOS platform doesn’t switch to the Julian calendar but stays in the proleptic Gregorian calendar.
    The difference in your output is exactly those 10 skipped days that were skipped in the transition from the Julian to the Gregorian.

    I can highly recommend this applet if you want to play around with different calendars to learn more about this stuff:
    http://www.cs.tau.ac.il/~nachum/calendar-book/Calendrica.html
    These guys also wrote a brilliant book on the subject.

    Also, Apple has a little section on Historical Dates in their documentation here: https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/DatesAndTimes/Articles/dtHist.html#//apple_ref/doc/uid/TP40010240-SW1
    However, they do not mention NSDateFormatter implementation differences on different platforms!

    Working with calendars is from hell – good luck 🙂

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

Sidebar

Related Questions

I have the following code: NSDateFormatter * df = [[NSDateFormatter alloc] init]; [df setDateFormat:@yyyy-MM-dd
I have this part of code: NSDate *date =nil; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]
For the same code, Eclipse shows warnings about unused variables, but compiling with javac
Take the same code that sits on nodejs.org home page. Serve a static file
Does anybody know why the same code from this page http://emacsformacosx.com/ would not render
I've got another problem in the same code... I'm getting this error: initialization method
We are running multiple domains through the same code and we want to save
I would like to use the same code for copying files to an FTP
I am using JQGrid I have it on 2 domains (same code)... On domain
Casus: How to edit and advance with the same code, from several distanced locations

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.