Hebrew Calendar in iOS

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Hebrew Calendar in iOS

Victor Engel
Dear Calendar People,

iOS has several objects that can be used to work with dates. Relevant to this discussion are the following objects:

NSCalendar - the object can be initialized with a particular calendar type, e.g., Gregorian, Hebrew, etc.

NSDateComponents - useful for specifying dates by components like year, month, day, hour, minute, etc.

NSDate - a date object that internally uses a time interval from some epoch.

For Hebrew dates, one uses a calendar object initialized with NSCalendarIdentifierHebrew. One can then get calendar components for any date, by passing the date to the calendar object:

   NSCalendar *cal = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierHebrew];

   NSDateComponents *comp = [cal components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour|NSCalendarUnitMinute fromDate:dateObject];


The components of the date can be accessed as properties of comp.

This question concerns the value of the month property for this calendar type. We can list the possible month values by asking the calendar for a list:

[cal monthSymbols]

This produces the following list:

(

Tishri,

Heshvan,

Kislev,

Tevet,

Shevat,

Adar I,

Adar,

Nisan,

Iyar,

Sivan,

Tamuz,

Av,

Elul,

Adar II

)


Relevantly, Adar I, Adar, and Adar II are all listed.


OK. With that as a background, I reference the calendar converter at 


https://www.hebcal.com/converter/?gd=15&gm=3&gy=2016&g2h=1


I've included parameters to specify a date relevant to my question. The converter converts this date to 5 Adar II 5776. However, if you inspect the date components retrieved using the steps, above, the month component returned is actually 7, not 13 as would be expected for Adar II.


Adar I occurs before Adar, but Adar II never seems to be returned. Maybe there is some other way to retrieve an output of Adar II. Is there anyone here who codes iOS or OS with Hebrew calendars that knows the answer to this? 


Victor

Reply | Threaded
Open this post in threaded view
|

Re: Hebrew Calendar in iOS

Amos Shapir-2
Hi Victor and calendar people,

It seems that for this code, "Adar II" is a just synonym for "Adar" for all purposes; the first form is used only for display in leap years.
The list you get is of strings which may represent month names, internally the code can assign to them any month number.

I did control-U to look at the source, it seems that internally the code uses Nissan as the first month.
The code is copyrighted to Michael J. Radwin, I guess you can locate him and ask directly.


On Sat, Sep 23, 2017 at 7:50 PM, Victor Engel <[hidden email]> wrote:
Dear Calendar People,

iOS has several objects that can be used to work with dates. Relevant to this discussion are the following objects:

NSCalendar - the object can be initialized with a particular calendar type, e.g., Gregorian, Hebrew, etc.

NSDateComponents - useful for specifying dates by components like year, month, day, hour, minute, etc.

NSDate - a date object that internally uses a time interval from some epoch.

For Hebrew dates, one uses a calendar object initialized with NSCalendarIdentifierHebrew. One can then get calendar components for any date, by passing the date to the calendar object:

   NSCalendar *cal = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierHebrew];

   NSDateComponents *comp = [cal components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour|NSCalendarUnitMinute fromDate:dateObject];


The components of the date can be accessed as properties of comp.

This question concerns the value of the month property for this calendar type. We can list the possible month values by asking the calendar for a list:

[cal monthSymbols]

This produces the following list:

(

Tishri,

Heshvan,

Kislev,

Tevet,

Shevat,

Adar I,

Adar,

Nisan,

Iyar,

Sivan,

Tamuz,

Av,

Elul,

Adar II

)


Relevantly, Adar I, Adar, and Adar II are all listed.


OK. With that as a background, I reference the calendar converter at 


https://www.hebcal.com/converter/?gd=15&gm=3&gy=2016&g2h=1


I've included parameters to specify a date relevant to my question. The converter converts this date to 5 Adar II 5776. However, if you inspect the date components retrieved using the steps, above, the month component returned is actually 7, not 13 as would be expected for Adar II.


Adar I occurs before Adar, but Adar II never seems to be returned. Maybe there is some other way to retrieve an output of Adar II. Is there anyone here who codes iOS or OS with Hebrew calendars that knows the answer to this? 


Victor




--
Amos Shapir
 
Reply | Threaded
Open this post in threaded view
|

Re: Hebrew Calendar in iOS

Victor Engel
Dear Amos and Calendar People,

I think Amos misunderstood the question. It was not about how the website is rendering dates. It is a question about the iOS API, which is not addressed there. The listing I gave of the months is in the order used by iOS. The calendar objects use a month number internally, with numbers starting at 1 for Tishri, 2 for Heshvan, etc. The names are stored in an array indexed from 0, so to reference the month name for a month one would access the array thusly:

[[cal monthSymbols][comp.month - 1], where comp is the calendar components object.

My comment was that while the array has elements for Adar, Adar I, and Adar II, in my testing, the components object never had a value of 14 for the month. Since my initial posting, I also did some testing with a property isLeap, which, according to documentation, returns true if the month is a leap month. But I didn't find any case where it returned true in a Hebrew calendar. If it did, one could use that to determine which month name to access.

I feel like I'm just missing something. 

Victor

On Sun, Sep 24, 2017 at 2:55 AM, Amos Shapir <[hidden email]> wrote:
Hi Victor and calendar people,

It seems that for this code, "Adar II" is a just synonym for "Adar" for all purposes; the first form is used only for display in leap years.
The list you get is of strings which may represent month names, internally the code can assign to them any month number.

I did control-U to look at the source, it seems that internally the code uses Nissan as the first month.
The code is copyrighted to Michael J. Radwin, I guess you can locate him and ask directly.


On Sat, Sep 23, 2017 at 7:50 PM, Victor Engel <[hidden email]> wrote:
Dear Calendar People,

iOS has several objects that can be used to work with dates. Relevant to this discussion are the following objects:

NSCalendar - the object can be initialized with a particular calendar type, e.g., Gregorian, Hebrew, etc.

NSDateComponents - useful for specifying dates by components like year, month, day, hour, minute, etc.

NSDate - a date object that internally uses a time interval from some epoch.

For Hebrew dates, one uses a calendar object initialized with NSCalendarIdentifierHebrew. One can then get calendar components for any date, by passing the date to the calendar object:

   NSCalendar *cal = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierHebrew];

   NSDateComponents *comp = [cal components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour|NSCalendarUnitMinute fromDate:dateObject];


The components of the date can be accessed as properties of comp.

This question concerns the value of the month property for this calendar type. We can list the possible month values by asking the calendar for a list:

[cal monthSymbols]

This produces the following list:

(

Tishri,

Heshvan,

Kislev,

Tevet,

Shevat,

Adar I,

Adar,

Nisan,

Iyar,

Sivan,

Tamuz,

Av,

Elul,

Adar II

)


Relevantly, Adar I, Adar, and Adar II are all listed.


OK. With that as a background, I reference the calendar converter at 


https://www.hebcal.com/converter/?gd=15&gm=3&gy=2016&g2h=1


I've included parameters to specify a date relevant to my question. The converter converts this date to 5 Adar II 5776. However, if you inspect the date components retrieved using the steps, above, the month component returned is actually 7, not 13 as would be expected for Adar II.


Adar I occurs before Adar, but Adar II never seems to be returned. Maybe there is some other way to retrieve an output of Adar II. Is there anyone here who codes iOS or OS with Hebrew calendars that knows the answer to this? 


Victor




--
Amos Shapir
 

Reply | Threaded
Open this post in threaded view
|

Re: Hebrew Calendar in iOS

Victor Engel
In reply to this post by Amos Shapir-2
Dear Calendar People,

Playing around with the API some more, trying different calendars (until I found a hit), I find that Hebrew, Gregorian, Indian, Islamic, and Coptic returned only false for isLeap. The Chinese calendar, however, returned true for isLeap for some months.

Victor

On Sun, Sep 24, 2017 at 2:55 AM, Amos Shapir <[hidden email]> wrote:
Hi Victor and calendar people,

It seems that for this code, "Adar II" is a just synonym for "Adar" for all purposes; the first form is used only for display in leap years.
The list you get is of strings which may represent month names, internally the code can assign to them any month number.

I did control-U to look at the source, it seems that internally the code uses Nissan as the first month.
The code is copyrighted to Michael J. Radwin, I guess you can locate him and ask directly.


On Sat, Sep 23, 2017 at 7:50 PM, Victor Engel <[hidden email]> wrote:
Dear Calendar People,

iOS has several objects that can be used to work with dates. Relevant to this discussion are the following objects:

NSCalendar - the object can be initialized with a particular calendar type, e.g., Gregorian, Hebrew, etc.

NSDateComponents - useful for specifying dates by components like year, month, day, hour, minute, etc.

NSDate - a date object that internally uses a time interval from some epoch.

For Hebrew dates, one uses a calendar object initialized with NSCalendarIdentifierHebrew. One can then get calendar components for any date, by passing the date to the calendar object:

   NSCalendar *cal = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierHebrew];

   NSDateComponents *comp = [cal components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour|NSCalendarUnitMinute fromDate:dateObject];


The components of the date can be accessed as properties of comp.

This question concerns the value of the month property for this calendar type. We can list the possible month values by asking the calendar for a list:

[cal monthSymbols]

This produces the following list:

(

Tishri,

Heshvan,

Kislev,

Tevet,

Shevat,

Adar I,

Adar,

Nisan,

Iyar,

Sivan,

Tamuz,

Av,

Elul,

Adar II

)


Relevantly, Adar I, Adar, and Adar II are all listed.


OK. With that as a background, I reference the calendar converter at 


https://www.hebcal.com/converter/?gd=15&gm=3&gy=2016&g2h=1


I've included parameters to specify a date relevant to my question. The converter converts this date to 5 Adar II 5776. However, if you inspect the date components retrieved using the steps, above, the month component returned is actually 7, not 13 as would be expected for Adar II.


Adar I occurs before Adar, but Adar II never seems to be returned. Maybe there is some other way to retrieve an output of Adar II. Is there anyone here who codes iOS or OS with Hebrew calendars that knows the answer to this? 


Victor




--
Amos Shapir
 

Reply | Threaded
Open this post in threaded view
|

Re: Hebrew Calendar in iOS

Victor Engel
Dear Calendar people,

So here is what I've decided to do. If I want to use Adar for regular years and Adar I and Adar for long years, I use the API as is, asking for the month name by indexing the list using the month number. If I want to use Adar I and Adar II for long years, I do the following:

If the month number is 7, then I get the day number and use it to get a date that number of days earlier (actually, I'm using day number + 1 days earlier to avoid time zone change issues). Then I ask for the month for that date. If it is 6, then I know it is a long year, and I can use Adar II. Otherwise I use Adar.

I'm not sure yet which I'll want to use. But I have a way to use either if I need to. It's a bit more computing than I wanted, but it works.

Victor

On Mon, Sep 25, 2017 at 1:28 PM, Victor Engel <[hidden email]> wrote:
Dear Calendar People,

Playing around with the API some more, trying different calendars (until I found a hit), I find that Hebrew, Gregorian, Indian, Islamic, and Coptic returned only false for isLeap. The Chinese calendar, however, returned true for isLeap for some months.

Victor

On Sun, Sep 24, 2017 at 2:55 AM, Amos Shapir <[hidden email]> wrote:
Hi Victor and calendar people,

It seems that for this code, "Adar II" is a just synonym for "Adar" for all purposes; the first form is used only for display in leap years.
The list you get is of strings which may represent month names, internally the code can assign to them any month number.

I did control-U to look at the source, it seems that internally the code uses Nissan as the first month.
The code is copyrighted to Michael J. Radwin, I guess you can locate him and ask directly.


On Sat, Sep 23, 2017 at 7:50 PM, Victor Engel <[hidden email]> wrote:
Dear Calendar People,

iOS has several objects that can be used to work with dates. Relevant to this discussion are the following objects:

NSCalendar - the object can be initialized with a particular calendar type, e.g., Gregorian, Hebrew, etc.

NSDateComponents - useful for specifying dates by components like year, month, day, hour, minute, etc.

NSDate - a date object that internally uses a time interval from some epoch.

For Hebrew dates, one uses a calendar object initialized with NSCalendarIdentifierHebrew. One can then get calendar components for any date, by passing the date to the calendar object:

   NSCalendar *cal = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierHebrew];

   NSDateComponents *comp = [cal components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour|NSCalendarUnitMinute fromDate:dateObject];


The components of the date can be accessed as properties of comp.

This question concerns the value of the month property for this calendar type. We can list the possible month values by asking the calendar for a list:

[cal monthSymbols]

This produces the following list:

(

Tishri,

Heshvan,

Kislev,

Tevet,

Shevat,

Adar I,

Adar,

Nisan,

Iyar,

Sivan,

Tamuz,

Av,

Elul,

Adar II

)


Relevantly, Adar I, Adar, and Adar II are all listed.


OK. With that as a background, I reference the calendar converter at 


https://www.hebcal.com/converter/?gd=15&gm=3&gy=2016&g2h=1


I've included parameters to specify a date relevant to my question. The converter converts this date to 5 Adar II 5776. However, if you inspect the date components retrieved using the steps, above, the month component returned is actually 7, not 13 as would be expected for Adar II.


Adar I occurs before Adar, but Adar II never seems to be returned. Maybe there is some other way to retrieve an output of Adar II. Is there anyone here who codes iOS or OS with Hebrew calendars that knows the answer to this? 


Victor




--
Amos Shapir
 


Reply | Threaded
Open this post in threaded view
|

Re: Hebrew Calendar in iOS

Karl Palmen

Dear Victor and Calendar People

 

I have difficulty understanding Victor here and I work in computing.

 

However I can make a guess:

 

Some function returns the month of a date given to it, as a number. Number 7 refers to either Adar or Adar II. Number 6 refers to Adar I, which does not occur in a 12-month year. All other months have a number determined by its name, regardless of the month’s position in the year.

 

Also I think isLeap is used only to differentiate a Chinese leap month from the preceding month, which has the same number. This means that if you are using that function in the Chinese calendar, you have to check whether the month returned by the function a leap month, unless you are sure, it cannot be a leap month.

 

 

From: East Carolina University Calendar discussion List [mailto:[hidden email]] On Behalf Of Victor Engel
Sent: 26 September 2017 03:18
To: [hidden email]
Subject: Re: Hebrew Calendar in iOS

 

Dear Calendar people,

 

So here is what I've decided to do. If I want to use Adar for regular years and Adar I and Adar for long years, I use the API as is, asking for the month name by indexing the list using the month number.

 

KARL ASKS: Does this mean that some function returns the month as a number?

 

If I want to use Adar I and Adar II for long years, I do the following:

 

If the month number is 7,

 

KARL ASKS: Is this the month number returned by that function?

 

then I get the day number and use it to get a date that number of days earlier (actually, I'm using day number + 1 days earlier to avoid time zone change issues). Then I ask for the month for that date. If it is 6, then I know it is a long year, and I can use Adar II. Otherwise I use Adar.

 

I'm not sure yet which I'll want to use. But I have a way to use either if I need to. It's a bit more computing than I wanted, but it works.

 

KARL REPLIES: If the answers to my previous two questions are not both yes, then I think you have to describe the function(s) you are referring to here. This can be a simplified description, which ignores such things such as time zone.

 

Karl

 

16(14(06

 

 

Victor

 

On Mon, Sep 25, 2017 at 1:28 PM, Victor Engel <[hidden email]> wrote:

Dear Calendar People,

 

Playing around with the API some more, trying different calendars (until I found a hit), I find that Hebrew, Gregorian, Indian, Islamic, and Coptic returned only false for isLeap. The Chinese calendar, however, returned true for isLeap for some months.

 

Victor

 

On Sun, Sep 24, 2017 at 2:55 AM, Amos Shapir <[hidden email]> wrote:

Hi Victor and calendar people,

It seems that for this code, "Adar II" is a just synonym for "Adar" for all purposes; the first form is used only for display in leap years.

The list you get is of strings which may represent month names, internally the code can assign to them any month number.

I did control-U to look at the source, it seems that internally the code uses Nissan as the first month.

The code is copyrighted to Michael J. Radwin, I guess you can locate him and ask directly.

 

On Sat, Sep 23, 2017 at 7:50 PM, Victor Engel <[hidden email]> wrote:

Dear Calendar People,

 

iOS has several objects that can be used to work with dates. Relevant to this discussion are the following objects:

 

NSCalendar - the object can be initialized with a particular calendar type, e.g., Gregorian, Hebrew, etc.

 

NSDateComponents - useful for specifying dates by components like year, month, day, hour, minute, etc.

 

NSDate - a date object that internally uses a time interval from some epoch.

 

For Hebrew dates, one uses a calendar object initialized with NSCalendarIdentifierHebrew. One can then get calendar components for any date, by passing the date to the calendar object:

 

   NSCalendar *cal = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierHebrew];

   NSDateComponents *comp = [cal components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour|NSCalendarUnitMinute fromDate:dateObject];

 

The components of the date can be accessed as properties of comp.

 

This question concerns the value of the month property for this calendar type. We can list the possible month values by asking the calendar for a list:

 

[cal monthSymbols]

 

This produces the following list:

 

(

Tishri,

Heshvan,

Kislev,

Tevet,

Shevat,

Adar I,

Adar,

Nisan,

Iyar,

Sivan,

Tamuz,

Av,

Elul,

Adar II

)

 

Relevantly, Adar I, Adar, and Adar II are all listed.

 

OK. With that as a background, I reference the calendar converter at 

 

https://www.hebcal.com/converter/?gd=15&gm=3&gy=2016&g2h=1

 

I've included parameters to specify a date relevant to my question. The converter converts this date to 5 Adar II 5776. However, if you inspect the date components retrieved using the steps, above, the month component returned is actually 7, not 13 as would be expected for Adar II.

 

Adar I occurs before Adar, but Adar II never seems to be returned. Maybe there is some other way to retrieve an output of Adar II. Is there anyone here who codes iOS or OS with Hebrew calendars that knows the answer to this? 

 

Victor




--

Amos Shapir

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: Hebrew Calendar in iOS

Victor Engel
Dear Karl and Calendar People,

Sorry for the confusion. I was trying not to put in too much detail but instead to give enough information for someone familiar with the API. I probably erred in posting here in the first place. But since I did, I can post more information to clarify.

The following classes of objects are used in iOS for working with dates (among others):

NSDate - at its core, it's just a serial number of seconds since epoch. But the object also has methods useful for all sorts of things, like computing intervals between dates, comparing dates, computing new dates from existing dates, etc. An NSDate object is independent of a calendar.

NSDateComponents - essentially consists of a set of properties describing a date or an interval. The properties include year, month, day, week, dayOfWeek, isLeap, etc. It is possible to have an NSDateComponents object that does not specify a date, for example if the year property is not set.

NSCalendar - an object initialized with a particular calendar type, e.g., Gregorian, Chinese, Hebrew, etc. This object knows how to take an NSDate object and compute an NSDateComponents object from it. Conversely, it can take an NSDateComponents object and compute NSDate objects from them.

NSDateFormatter - an object that can format a date according to a format string. Tokens used in the format string specify how the various components are formatted. The websit nsdateformatter.com has a nice presentation of the formats with examples. The NSDateFormatter object formats dates according not only to the format string but also to the locale setting. There are also what you could call macros to get standard formats as set up in preferences by the user.

My original question would have been resolved by using an NSDateFormatter object. However, those objects are expensive. They require a calendar object, a locale object, a date object, and a format string. I was hoping for a way to get the month name just from an NSDateComponents object.

For the Hebrew calendar, the month property of NSDateComponents objects is set as follows:

1 for Tishri
2 for Heshvan
.
.
7 for Adar
8 for Nisan
.
.
13 for Elul

Asking an NSCalendar object initialized as a Hebrew calendar for a list of month symbols returns an array with the month names in order, indexed starting from 0 (Objective C is unix-based, so arrays are indexed starting from 0). So to get a month name from the list of months, using a date components object, you'd do something like this:

NSDateComponents *comp = /*some code to get an NSDateCompoments object corresponding to a date */
NSCalendar *cal = /*some code to get an NSCalendar object for a Hebrew calendar */
NSString *monthName = [cal monthNames][comp.month - 1];

My point was that using this method, both Adar in regular years and Adar II in leap years return Adar because the NSDateComponents object always returns 7 for  that month, whether or not it is in a leap year. In leap years, the month before 7 is 6. In non-leap years, the month before 7 is 5.

Using NSDateFormatter, on the other hand, using the format string @"MMMM" returns Adar II. I was looking for an efficient way (not relying on NSDateFormatter) to return Adar II.

I will probably just switch to using NSDateFormatter.

Victor

On Tue, Sep 26, 2017 at 7:05 AM, Karl Palmen <[hidden email]> wrote:

Dear Victor and Calendar People

 

I have difficulty understanding Victor here and I work in computing.

 

However I can make a guess:

 

Some function returns the month of a date given to it, as a number. Number 7 refers to either Adar or Adar II. Number 6 refers to Adar I, which does not occur in a 12-month year. All other months have a number determined by its name, regardless of the month’s position in the year.

 

Also I think isLeap is used only to differentiate a Chinese leap month from the preceding month, which has the same number. This means that if you are using that function in the Chinese calendar, you have to check whether the month returned by the function a leap month, unless you are sure, it cannot be a leap month.

 

 

From: East Carolina University Calendar discussion List [mailto:[hidden email]] On Behalf Of Victor Engel
Sent: 26 September 2017 03:18
To: [hidden email]
Subject: Re: Hebrew Calendar in iOS

 

Dear Calendar people,

 

So here is what I've decided to do. If I want to use Adar for regular years and Adar I and Adar for long years, I use the API as is, asking for the month name by indexing the list using the month number.

 

KARL ASKS: Does this mean that some function returns the month as a number?

 

If I want to use Adar I and Adar II for long years, I do the following:

 

If the month number is 7,

 

KARL ASKS: Is this the month number returned by that function?

 

then I get the day number and use it to get a date that number of days earlier (actually, I'm using day number + 1 days earlier to avoid time zone change issues). Then I ask for the month for that date. If it is 6, then I know it is a long year, and I can use Adar II. Otherwise I use Adar.

 

I'm not sure yet which I'll want to use. But I have a way to use either if I need to. It's a bit more computing than I wanted, but it works.

 

KARL REPLIES: If the answers to my previous two questions are not both yes, then I think you have to describe the function(s) you are referring to here. This can be a simplified description, which ignores such things such as time zone.

 

Karl

 

16(14(06

 

 

Victor

 

On Mon, Sep 25, 2017 at 1:28 PM, Victor Engel <[hidden email]> wrote:

Dear Calendar People,

 

Playing around with the API some more, trying different calendars (until I found a hit), I find that Hebrew, Gregorian, Indian, Islamic, and Coptic returned only false for isLeap. The Chinese calendar, however, returned true for isLeap for some months.

 

Victor

 

On Sun, Sep 24, 2017 at 2:55 AM, Amos Shapir <[hidden email]> wrote:

Hi Victor and calendar people,

It seems that for this code, "Adar II" is a just synonym for "Adar" for all purposes; the first form is used only for display in leap years.

The list you get is of strings which may represent month names, internally the code can assign to them any month number.

I did control-U to look at the source, it seems that internally the code uses Nissan as the first month.

The code is copyrighted to Michael J. Radwin, I guess you can locate him and ask directly.

 

On Sat, Sep 23, 2017 at 7:50 PM, Victor Engel <[hidden email]> wrote:

Dear Calendar People,

 

iOS has several objects that can be used to work with dates. Relevant to this discussion are the following objects:

 

NSCalendar - the object can be initialized with a particular calendar type, e.g., Gregorian, Hebrew, etc.

 

NSDateComponents - useful for specifying dates by components like year, month, day, hour, minute, etc.

 

NSDate - a date object that internally uses a time interval from some epoch.

 

For Hebrew dates, one uses a calendar object initialized with NSCalendarIdentifierHebrew. One can then get calendar components for any date, by passing the date to the calendar object:

 

   NSCalendar *cal = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierHebrew];

   NSDateComponents *comp = [cal components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour|NSCalendarUnitMinute fromDate:dateObject];

 

The components of the date can be accessed as properties of comp.

 

This question concerns the value of the month property for this calendar type. We can list the possible month values by asking the calendar for a list:

 

[cal monthSymbols]

 

This produces the following list:

 

(

Tishri,

Heshvan,

Kislev,

Tevet,

Shevat,

Adar I,

Adar,

Nisan,

Iyar,

Sivan,

Tamuz,

Av,

Elul,

Adar II

)

 

Relevantly, Adar I, Adar, and Adar II are all listed.

 

OK. With that as a background, I reference the calendar converter at 

 

https://www.hebcal.com/converter/?gd=15&gm=3&gy=2016&g2h=1

 

I've included parameters to specify a date relevant to my question. The converter converts this date to 5 Adar II 5776. However, if you inspect the date components retrieved using the steps, above, the month component returned is actually 7, not 13 as would be expected for Adar II.

 

Adar I occurs before Adar, but Adar II never seems to be returned. Maybe there is some other way to retrieve an output of Adar II. Is there anyone here who codes iOS or OS with Hebrew calendars that knows the answer to this? 

 

Victor




--

Amos Shapir

 

 

 


Reply | Threaded
Open this post in threaded view
|

Re: Hebrew Calendar in iOS

Karl Palmen

Dear Victor and Calendar People

 

From: East Carolina University Calendar discussion List [mailto:[hidden email]] On Behalf Of Victor Engel
Sent: 26 September 2017 16:34
To: [hidden email]
Subject: Re: Hebrew Calendar in iOS

 

Dear Karl and Calendar People,

 

Sorry for the confusion. I was trying not to put in too much detail but instead to give enough information for someone familiar with the API. I probably erred in posting here in the first place. But since I did, I can post more information to clarify.

 

KARL REPLIES: Thank you Victor for this reply. I can understand it.  He has not answered my questions explicitly.

I think the function I’m referring to is the function of NSDateComponents that returns its month property, having been converted from an NSDate, by an NSCalendar.

 

NSDate corresponds to what I’d call a day and NSDateComponents corresponds to what I’d call a date, without requirement that it is complete. NSDateFormatter seems to be an expression of a date in a given locale.

 

Karl

 

16(14(06

 

 

The following classes of objects are used in iOS for working with dates (among others):

 

NSDate - at its core, it's just a serial number of seconds since epoch. But the object also has methods useful for all sorts of things, like computing intervals between dates, comparing dates, computing new dates from existing dates, etc. An NSDate object is independent of a calendar.

 

NSDateComponents - essentially consists of a set of properties describing a date or an interval. The properties include year, month, day, week, dayOfWeek, isLeap, etc. It is possible to have an NSDateComponents object that does not specify a date, for example if the year property is not set.

 

NSCalendar - an object initialized with a particular calendar type, e.g., Gregorian, Chinese, Hebrew, etc. This object knows how to take an NSDate object and compute an NSDateComponents object from it. Conversely, it can take an NSDateComponents object and compute NSDate objects from them.

 

NSDateFormatter - an object that can format a date according to a format string. Tokens used in the format string specify how the various components are formatted. The websit nsdateformatter.com has a nice presentation of the formats with examples. The NSDateFormatter object formats dates according not only to the format string but also to the locale setting. There are also what you could call macros to get standard formats as set up in preferences by the user.

 

My original question would have been resolved by using an NSDateFormatter object. However, those objects are expensive. They require a calendar object, a locale object, a date object, and a format string. I was hoping for a way to get the month name just from an NSDateComponents object.

 

For the Hebrew calendar, the month property of NSDateComponents objects is set as follows:

 

1 for Tishri

2 for Heshvan

.

.

7 for Adar

8 for Nisan

.

.

13 for Elul

 

Asking an NSCalendar object initialized as a Hebrew calendar for a list of month symbols returns an array with the month names in order, indexed starting from 0 (Objective C is unix-based, so arrays are indexed starting from 0). So to get a month name from the list of months, using a date components object, you'd do something like this:

 

NSDateComponents *comp = /*some code to get an NSDateCompoments object corresponding to a date */

NSCalendar *cal = /*some code to get an NSCalendar object for a Hebrew calendar */

NSString *monthName = [cal monthNames][comp.month - 1];

 

My point was that using this method, both Adar in regular years and Adar II in leap years return Adar because the NSDateComponents object always returns 7 for  that month, whether or not it is in a leap year. In leap years, the month before 7 is 6. In non-leap years, the month before 7 is 5.

 

Using NSDateFormatter, on the other hand, using the format string @"MMMM" returns Adar II. I was looking for an efficient way (not relying on NSDateFormatter) to return Adar II.

 

I will probably just switch to using NSDateFormatter.

 

Victor

 

On Tue, Sep 26, 2017 at 7:05 AM, Karl Palmen <[hidden email]> wrote:

Dear Victor and Calendar People

 

I have difficulty understanding Victor here and I work in computing.

 

However I can make a guess:

 

Some function returns the month of a date given to it, as a number. Number 7 refers to either Adar or Adar II. Number 6 refers to Adar I, which does not occur in a 12-month year. All other months have a number determined by its name, regardless of the month’s position in the year.

 

Also I think isLeap is used only to differentiate a Chinese leap month from the preceding month, which has the same number. This means that if you are using that function in the Chinese calendar, you have to check whether the month returned by the function a leap month, unless you are sure, it cannot be a leap month.

 

 

From: East Carolina University Calendar discussion List [mailto:[hidden email]] On Behalf Of Victor Engel
Sent: 26 September 2017 03:18
To: [hidden email]
Subject: Re: Hebrew Calendar in iOS

 

Dear Calendar people,

 

So here is what I've decided to do. If I want to use Adar for regular years and Adar I and Adar for long years, I use the API as is, asking for the month name by indexing the list using the month number.

 

KARL ASKS: Does this mean that some function returns the month as a number?

 

If I want to use Adar I and Adar II for long years, I do the following:

 

If the month number is 7,

 

KARL ASKS: Is this the month number returned by that function?

 

then I get the day number and use it to get a date that number of days earlier (actually, I'm using day number + 1 days earlier to avoid time zone change issues). Then I ask for the month for that date. If it is 6, then I know it is a long year, and I can use Adar II. Otherwise I use Adar.

 

I'm not sure yet which I'll want to use. But I have a way to use either if I need to. It's a bit more computing than I wanted, but it works.

 

KARL REPLIES: If the answers to my previous two questions are not both yes, then I think you have to describe the function(s) you are referring to here. This can be a simplified description, which ignores such things such as time zone.

 

Karl

 

16(14(06

 

 

Victor

 

On Mon, Sep 25, 2017 at 1:28 PM, Victor Engel <[hidden email]> wrote:

Dear Calendar People,

 

Playing around with the API some more, trying different calendars (until I found a hit), I find that Hebrew, Gregorian, Indian, Islamic, and Coptic returned only false for isLeap. The Chinese calendar, however, returned true for isLeap for some months.

 

Victor

 

On Sun, Sep 24, 2017 at 2:55 AM, Amos Shapir <[hidden email]> wrote:

Hi Victor and calendar people,

It seems that for this code, "Adar II" is a just synonym for "Adar" for all purposes; the first form is used only for display in leap years.

The list you get is of strings which may represent month names, internally the code can assign to them any month number.

I did control-U to look at the source, it seems that internally the code uses Nissan as the first month.

The code is copyrighted to Michael J. Radwin, I guess you can locate him and ask directly.

 

On Sat, Sep 23, 2017 at 7:50 PM, Victor Engel <[hidden email]> wrote:

Dear Calendar People,

 

iOS has several objects that can be used to work with dates. Relevant to this discussion are the following objects:

 

NSCalendar - the object can be initialized with a particular calendar type, e.g., Gregorian, Hebrew, etc.

 

NSDateComponents - useful for specifying dates by components like year, month, day, hour, minute, etc.

 

NSDate - a date object that internally uses a time interval from some epoch.

 

For Hebrew dates, one uses a calendar object initialized with NSCalendarIdentifierHebrew. One can then get calendar components for any date, by passing the date to the calendar object:

 

   NSCalendar *cal = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierHebrew];

   NSDateComponents *comp = [cal components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour|NSCalendarUnitMinute fromDate:dateObject];

 

The components of the date can be accessed as properties of comp.

 

This question concerns the value of the month property for this calendar type. We can list the possible month values by asking the calendar for a list:

 

[cal monthSymbols]

 

This produces the following list:

 

(

Tishri,

Heshvan,

Kislev,

Tevet,

Shevat,

Adar I,

Adar,

Nisan,

Iyar,

Sivan,

Tamuz,

Av,

Elul,

Adar II

)

 

Relevantly, Adar I, Adar, and Adar II are all listed.

 

OK. With that as a background, I reference the calendar converter at 

 

https://www.hebcal.com/converter/?gd=15&gm=3&gy=2016&g2h=1

 

I've included parameters to specify a date relevant to my question. The converter converts this date to 5 Adar II 5776. However, if you inspect the date components retrieved using the steps, above, the month component returned is actually 7, not 13 as would be expected for Adar II.

 

Adar I occurs before Adar, but Adar II never seems to be returned. Maybe there is some other way to retrieve an output of Adar II. Is there anyone here who codes iOS or OS with Hebrew calendars that knows the answer to this? 

 

Victor




--

Amos Shapir

 

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: Hebrew Calendar in iOS

Victor Engel
Dear Karl and Calendar People,

On Tue, Sep 26, 2017 at 11:08 AM, Karl Palmen <[hidden email]> wrote:

Dear Victor and Calendar People

 

From: East Carolina University Calendar discussion List [mailto:[hidden email]] On Behalf Of Victor Engel
Sent: 26 September 2017 16:34
To: [hidden email]
Subject: Re: Hebrew Calendar in iOS

 

Dear Karl and Calendar People,

 

Sorry for the confusion. I was trying not to put in too much detail but instead to give enough information for someone familiar with the API. I probably erred in posting here in the first place. But since I did, I can post more information to clarify.

 

KARL REPLIES: Thank you Victor for this reply. I can understand it.  He has not answered my questions explicitly.


I'm sorry if I missed a question. I did not see a specific question.
 

I think the function I’m referring to is the function of NSDateComponents that returns its month property, having been converted from an NSDate, by an NSCalendar.


That function would be:

NSDateComponents *comp = [cal components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay fromDate:self.testDate];

The units desired are listed with a | symbol between them to create a bitmap of the units desired. The NSCalendar object then populates the corresponding properties (year, month, and day in this example) into the NSDateComponents object. It is the NSCalendar object that must do this, because it is the object that knows the inner workings of the calendar.
 

 

NSDate corresponds to what I’d call a day


I'd characterize it as an instant in time. It has both a date and time component and is essentially a serial number of seconds from epoch.
 

and NSDateComponents corresponds to what I’d call a date, without requirement that it is complete. NSDateFormatter seems to be an expression of a date in a given locale.


Yes.
 

 

Karl

 

16(14(06

 

 

The following classes of objects are used in iOS for working with dates (among others):

 

NSDate - at its core, it's just a serial number of seconds since epoch. But the object also has methods useful for all sorts of things, like computing intervals between dates, comparing dates, computing new dates from existing dates, etc. An NSDate object is independent of a calendar.

 

NSDateComponents - essentially consists of a set of properties describing a date or an interval. The properties include year, month, day, week, dayOfWeek, isLeap, etc. It is possible to have an NSDateComponents object that does not specify a date, for example if the year property is not set.

 

NSCalendar - an object initialized with a particular calendar type, e.g., Gregorian, Chinese, Hebrew, etc. This object knows how to take an NSDate object and compute an NSDateComponents object from it. Conversely, it can take an NSDateComponents object and compute NSDate objects from them.

 

NSDateFormatter - an object that can format a date according to a format string. Tokens used in the format string specify how the various components are formatted. The websit nsdateformatter.com has a nice presentation of the formats with examples. The NSDateFormatter object formats dates according not only to the format string but also to the locale setting. There are also what you could call macros to get standard formats as set up in preferences by the user.

 

My original question would have been resolved by using an NSDateFormatter object. However, those objects are expensive. They require a calendar object, a locale object, a date object, and a format string. I was hoping for a way to get the month name just from an NSDateComponents object.

 

For the Hebrew calendar, the month property of NSDateComponents objects is set as follows:

 

1 for Tishri

2 for Heshvan

.

.

7 for Adar

8 for Nisan

.

.

13 for Elul

 

Asking an NSCalendar object initialized as a Hebrew calendar for a list of month symbols returns an array with the month names in order, indexed starting from 0 (Objective C is unix-based, so arrays are indexed starting from 0). So to get a month name from the list of months, using a date components object, you'd do something like this:

 

NSDateComponents *comp = /*some code to get an NSDateCompoments object corresponding to a date */

NSCalendar *cal = /*some code to get an NSCalendar object for a Hebrew calendar */

NSString *monthName = [cal monthNames][comp.month - 1];

 

My point was that using this method, both Adar in regular years and Adar II in leap years return Adar because the NSDateComponents object always returns 7 for  that month, whether or not it is in a leap year. In leap years, the month before 7 is 6. In non-leap years, the month before 7 is 5.

 

Using NSDateFormatter, on the other hand, using the format string @"MMMM" returns Adar II. I was looking for an efficient way (not relying on NSDateFormatter) to return Adar II.

 

I will probably just switch to using NSDateFormatter.

 

Victor

 

On Tue, Sep 26, 2017 at 7:05 AM, Karl Palmen <[hidden email]> wrote:

Dear Victor and Calendar People

 

I have difficulty understanding Victor here and I work in computing.

 

However I can make a guess:

 

Some function returns the month of a date given to it, as a number. Number 7 refers to either Adar or Adar II. Number 6 refers to Adar I, which does not occur in a 12-month year. All other months have a number determined by its name, regardless of the month’s position in the year.

 

Also I think isLeap is used only to differentiate a Chinese leap month from the preceding month, which has the same number. This means that if you are using that function in the Chinese calendar, you have to check whether the month returned by the function a leap month, unless you are sure, it cannot be a leap month.

 

 

From: East Carolina University Calendar discussion List [mailto:[hidden email]] On Behalf Of Victor Engel
Sent: 26 September 2017 03:18
To: [hidden email]
Subject: Re: Hebrew Calendar in iOS

 

Dear Calendar people,

 

So here is what I've decided to do. If I want to use Adar for regular years and Adar I and Adar for long years, I use the API as is, asking for the month name by indexing the list using the month number.

 

KARL ASKS: Does this mean that some function returns the month as a number?

 

If I want to use Adar I and Adar II for long years, I do the following:

 

If the month number is 7,

 

KARL ASKS: Is this the month number returned by that function?

 

then I get the day number and use it to get a date that number of days earlier (actually, I'm using day number + 1 days earlier to avoid time zone change issues). Then I ask for the month for that date. If it is 6, then I know it is a long year, and I can use Adar II. Otherwise I use Adar.

 

I'm not sure yet which I'll want to use. But I have a way to use either if I need to. It's a bit more computing than I wanted, but it works.

 

KARL REPLIES: If the answers to my previous two questions are not both yes, then I think you have to describe the function(s) you are referring to here. This can be a simplified description, which ignores such things such as time zone.

 

Karl

 

16(14(06

 

 

Victor

 

On Mon, Sep 25, 2017 at 1:28 PM, Victor Engel <[hidden email]> wrote:

Dear Calendar People,

 

Playing around with the API some more, trying different calendars (until I found a hit), I find that Hebrew, Gregorian, Indian, Islamic, and Coptic returned only false for isLeap. The Chinese calendar, however, returned true for isLeap for some months.

 

Victor

 

On Sun, Sep 24, 2017 at 2:55 AM, Amos Shapir <[hidden email]> wrote:

Hi Victor and calendar people,

It seems that for this code, "Adar II" is a just synonym for "Adar" for all purposes; the first form is used only for display in leap years.

The list you get is of strings which may represent month names, internally the code can assign to them any month number.

I did control-U to look at the source, it seems that internally the code uses Nissan as the first month.

The code is copyrighted to Michael J. Radwin, I guess you can locate him and ask directly.

 

On Sat, Sep 23, 2017 at 7:50 PM, Victor Engel <[hidden email]> wrote:

Dear Calendar People,

 

iOS has several objects that can be used to work with dates. Relevant to this discussion are the following objects:

 

NSCalendar - the object can be initialized with a particular calendar type, e.g., Gregorian, Hebrew, etc.

 

NSDateComponents - useful for specifying dates by components like year, month, day, hour, minute, etc.

 

NSDate - a date object that internally uses a time interval from some epoch.

 

For Hebrew dates, one uses a calendar object initialized with NSCalendarIdentifierHebrew. One can then get calendar components for any date, by passing the date to the calendar object:

 

   NSCalendar *cal = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierHebrew];

   NSDateComponents *comp = [cal components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour|NSCalendarUnitMinute fromDate:dateObject];

 

The components of the date can be accessed as properties of comp.

 

This question concerns the value of the month property for this calendar type. We can list the possible month values by asking the calendar for a list:

 

[cal monthSymbols]

 

This produces the following list:

 

(

Tishri,

Heshvan,

Kislev,

Tevet,

Shevat,

Adar I,

Adar,

Nisan,

Iyar,

Sivan,

Tamuz,

Av,

Elul,

Adar II

)

 

Relevantly, Adar I, Adar, and Adar II are all listed.

 

OK. With that as a background, I reference the calendar converter at 

 

https://www.hebcal.com/converter/?gd=15&gm=3&gy=2016&g2h=1

 

I've included parameters to specify a date relevant to my question. The converter converts this date to 5 Adar II 5776. However, if you inspect the date components retrieved using the steps, above, the month component returned is actually 7, not 13 as would be expected for Adar II.

 

Adar I occurs before Adar, but Adar II never seems to be returned. Maybe there is some other way to retrieve an output of Adar II. Is there anyone here who codes iOS or OS with Hebrew calendars that knows the answer to this? 

 

Victor




--

Amos Shapir

 

 

 

 


Reply | Threaded
Open this post in threaded view
|

Re: Hebrew Calendar in iOS

Karl Palmen

Dear Victor and Calendar People

 

Thank you for your reply. It makes it clear.

 

Karl

 

16(14(07

 

From: East Carolina University Calendar discussion List [mailto:[hidden email]] On Behalf Of Victor Engel
Sent: 26 September 2017 17:20
To: [hidden email]
Subject: Re: Hebrew Calendar in iOS

 

Dear Karl and Calendar People,

 

On Tue, Sep 26, 2017 at 11:08 AM, Karl Palmen <[hidden email]> wrote:

Dear Victor and Calendar People

 

From: East Carolina University Calendar discussion List [mailto:[hidden email]] On Behalf Of Victor Engel
Sent: 26 September 2017 16:34
To: [hidden email]
Subject: Re: Hebrew Calendar in iOS

 

Dear Karl and Calendar People,

 

Sorry for the confusion. I was trying not to put in too much detail but instead to give enough information for someone familiar with the API. I probably erred in posting here in the first place. But since I did, I can post more information to clarify.

 

KARL REPLIES: Thank you Victor for this reply. I can understand it.  He has not answered my questions explicitly.

 

I'm sorry if I missed a question. I did not see a specific question.

 

I think the function I’m referring to is the function of NSDateComponents that returns its month property, having been converted from an NSDate, by an NSCalendar.

 

That function would be:

 

NSDateComponents *comp = [cal components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay fromDate:self.testDate];

 

The units desired are listed with a | symbol between them to create a bitmap of the units desired. The NSCalendar object then populates the corresponding properties (year, month, and day in this example) into the NSDateComponents object. It is the NSCalendar object that must do this, because it is the object that knows the inner workings of the calendar.

 

 

NSDate corresponds to what I’d call a day

 

I'd characterize it as an instant in time. It has both a date and time component and is essentially a serial number of seconds from epoch.

 

and NSDateComponents corresponds to what I’d call a date, without requirement that it is complete. NSDateFormatter seems to be an expression of a date in a given locale.

 

Yes.

 

 

Karl

 

16(14(06

 

 

The following classes of objects are used in iOS for working with dates (among others):

 

NSDate - at its core, it's just a serial number of seconds since epoch. But the object also has methods useful for all sorts of things, like computing intervals between dates, comparing dates, computing new dates from existing dates, etc. An NSDate object is independent of a calendar.

 

NSDateComponents - essentially consists of a set of properties describing a date or an interval. The properties include year, month, day, week, dayOfWeek, isLeap, etc. It is possible to have an NSDateComponents object that does not specify a date, for example if the year property is not set.

 

NSCalendar - an object initialized with a particular calendar type, e.g., Gregorian, Chinese, Hebrew, etc. This object knows how to take an NSDate object and compute an NSDateComponents object from it. Conversely, it can take an NSDateComponents object and compute NSDate objects from them.

 

NSDateFormatter - an object that can format a date according to a format string. Tokens used in the format string specify how the various components are formatted. The websit nsdateformatter.com has a nice presentation of the formats with examples. The NSDateFormatter object formats dates according not only to the format string but also to the locale setting. There are also what you could call macros to get standard formats as set up in preferences by the user.

 

My original question would have been resolved by using an NSDateFormatter object. However, those objects are expensive. They require a calendar object, a locale object, a date object, and a format string. I was hoping for a way to get the month name just from an NSDateComponents object.

 

For the Hebrew calendar, the month property of NSDateComponents objects is set as follows:

 

1 for Tishri

2 for Heshvan

.

.

7 for Adar

8 for Nisan

.

.

13 for Elul

 

Asking an NSCalendar object initialized as a Hebrew calendar for a list of month symbols returns an array with the month names in order, indexed starting from 0 (Objective C is unix-based, so arrays are indexed starting from 0). So to get a month name from the list of months, using a date components object, you'd do something like this:

 

NSDateComponents *comp = /*some code to get an NSDateCompoments object corresponding to a date */

NSCalendar *cal = /*some code to get an NSCalendar object for a Hebrew calendar */

NSString *monthName = [cal monthNames][comp.month - 1];

 

My point was that using this method, both Adar in regular years and Adar II in leap years return Adar because the NSDateComponents object always returns 7 for  that month, whether or not it is in a leap year. In leap years, the month before 7 is 6. In non-leap years, the month before 7 is 5.

 

Using NSDateFormatter, on the other hand, using the format string @"MMMM" returns Adar II. I was looking for an efficient way (not relying on NSDateFormatter) to return Adar II.

 

I will probably just switch to using NSDateFormatter.

 

Victor

 

On Tue, Sep 26, 2017 at 7:05 AM, Karl Palmen <[hidden email]> wrote:

Dear Victor and Calendar People

 

I have difficulty understanding Victor here and I work in computing.

 

However I can make a guess:

 

Some function returns the month of a date given to it, as a number. Number 7 refers to either Adar or Adar II. Number 6 refers to Adar I, which does not occur in a 12-month year. All other months have a number determined by its name, regardless of the month’s position in the year.

 

Also I think isLeap is used only to differentiate a Chinese leap month from the preceding month, which has the same number. This means that if you are using that function in the Chinese calendar, you have to check whether the month returned by the function a leap month, unless you are sure, it cannot be a leap month.

 

 

From: East Carolina University Calendar discussion List [mailto:[hidden email]] On Behalf Of Victor Engel
Sent: 26 September 2017 03:18
To: [hidden email]
Subject: Re: Hebrew Calendar in iOS

 

Dear Calendar people,

 

So here is what I've decided to do. If I want to use Adar for regular years and Adar I and Adar for long years, I use the API as is, asking for the month name by indexing the list using the month number.

 

KARL ASKS: Does this mean that some function returns the month as a number?

 

If I want to use Adar I and Adar II for long years, I do the following:

 

If the month number is 7,

 

KARL ASKS: Is this the month number returned by that function?

 

then I get the day number and use it to get a date that number of days earlier (actually, I'm using day number + 1 days earlier to avoid time zone change issues). Then I ask for the month for that date. If it is 6, then I know it is a long year, and I can use Adar II. Otherwise I use Adar.

 

I'm not sure yet which I'll want to use. But I have a way to use either if I need to. It's a bit more computing than I wanted, but it works.

 

KARL REPLIES: If the answers to my previous two questions are not both yes, then I think you have to describe the function(s) you are referring to here. This can be a simplified description, which ignores such things such as time zone.

 

Karl

 

16(14(06

 

 

Victor

 

On Mon, Sep 25, 2017 at 1:28 PM, Victor Engel <[hidden email]> wrote:

Dear Calendar People,

 

Playing around with the API some more, trying different calendars (until I found a hit), I find that Hebrew, Gregorian, Indian, Islamic, and Coptic returned only false for isLeap. The Chinese calendar, however, returned true for isLeap for some months.

 

Victor

 

On Sun, Sep 24, 2017 at 2:55 AM, Amos Shapir <[hidden email]> wrote:

Hi Victor and calendar people,

It seems that for this code, "Adar II" is a just synonym for "Adar" for all purposes; the first form is used only for display in leap years.

The list you get is of strings which may represent month names, internally the code can assign to them any month number.

I did control-U to look at the source, it seems that internally the code uses Nissan as the first month.

The code is copyrighted to Michael J. Radwin, I guess you can locate him and ask directly.

 

On Sat, Sep 23, 2017 at 7:50 PM, Victor Engel <[hidden email]> wrote:

Dear Calendar People,

 

iOS has several objects that can be used to work with dates. Relevant to this discussion are the following objects:

 

NSCalendar - the object can be initialized with a particular calendar type, e.g., Gregorian, Hebrew, etc.

 

NSDateComponents - useful for specifying dates by components like year, month, day, hour, minute, etc.

 

NSDate - a date object that internally uses a time interval from some epoch.

 

For Hebrew dates, one uses a calendar object initialized with NSCalendarIdentifierHebrew. One can then get calendar components for any date, by passing the date to the calendar object:

 

   NSCalendar *cal = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierHebrew];

   NSDateComponents *comp = [cal components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour|NSCalendarUnitMinute fromDate:dateObject];

 

The components of the date can be accessed as properties of comp.

 

This question concerns the value of the month property for this calendar type. We can list the possible month values by asking the calendar for a list:

 

[cal monthSymbols]

 

This produces the following list:

 

(

Tishri,

Heshvan,

Kislev,

Tevet,

Shevat,

Adar I,

Adar,

Nisan,

Iyar,

Sivan,

Tamuz,

Av,

Elul,

Adar II

)

 

Relevantly, Adar I, Adar, and Adar II are all listed.

 

OK. With that as a background, I reference the calendar converter at 

 

https://www.hebcal.com/converter/?gd=15&gm=3&gy=2016&g2h=1

 

I've included parameters to specify a date relevant to my question. The converter converts this date to 5 Adar II 5776. However, if you inspect the date components retrieved using the steps, above, the month component returned is actually 7, not 13 as would be expected for Adar II.

 

Adar I occurs before Adar, but Adar II never seems to be returned. Maybe there is some other way to retrieve an output of Adar II. Is there anyone here who codes iOS or OS with Hebrew calendars that knows the answer to this? 

 

Victor




--

Amos Shapir