In Russia the first day of the week is Monday. In the United States - Sunday. On Linux nl_langinfo(_NL_TIME_FIRST_WEEKDAY) return 0 for Sun or 1 for Mon. How do I get too in MacOS X with c-code?
I haven't tried it myself, but from skimming the docs, you can get a CFLocale instance (reference) and get it's CFCalendar instance using:
CFLocaleGetValue(locale, kCFLocaleCalendar)
And get the first day of the week from the CFCalendar instance using CFCalendarGetFirstWeekday() (reference).
My guess would be to use CFDateRef and CFLocaleRef opaque types and associated CFDate* and CFLocale* functions from CoreFoundation framework.
UPDATE
After some digging I found the function you need. It appears that you have to use CFCalendar for this. From apple's documentation:
CFCalendarGetFirstWeekday
Returns the index of first weekday for a specified calendar.
CFIndex CFCalendarGetFirstWeekday (
CFCalendarRef calendar
);
Parameters
calendar
The calendar to examine.
Return Value
The index of the first weekday of the specified calendar.
Related
I have an recurring event on the 7th of each month but am struggling to find an RRule that I can put into a text editor and import into google calendar. I need the rule to put the event on the last week day if the 7th falls on a weekend. Thanks in advance.
Due to the fallback condition, I don't think you can achieve this only defining a RRULE, unfortunately.
RRULE in Google Calendar follows RFC 5545 specification.
With RFC 5545, regarding monthly recurrences, you can either set the recurring rule for a specific day of the month (e.g. always on the 7th of the month would be RRULE:FREQ=MONTHLY;BYMONTHDAY=7) or a specific offset of day of the week within a month (e.g. second to last weekday of the month would be RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-2).
Only using this specification, I don't believe there is a way to select the previous (or next) weekday in reference to the 7th day of the month.
However you can always achieve this by using a script to generate the dates or interpret an existing list you already have before insert them on Google Calendar.
To correctly setup the calendar on my project, I need to know which day is the first of the week in Tanzania.
Seems like Google doesn't know, do you?
I am referring to the main source of internationalization data in IT-world (used for Java, C# etc.):
There is no explicit entry for TZ (= ISO-3166-2 code of Tanzania) in the weekData-section of CLDR-data. In such a case CLDR-data of unicode corporation says that the code "001" should be selected. And the data for "001" are:
Monday as first day of week and 1 as minimal count of first week in year.
I am trying to build a week view of the month with customized cells, so the Calendar class won't work for me.
I am having trouble knowing on which day the month starts. For example, January 1st was a Friday. Also, I need to know how many days a given month has.
Without telling me the exact code, can you tell me the variables or methods I could use for this?
Look at the actual code for the Calendar class here: http://github.com/codenameone/CodenameOne/
Just set java.util.Calendar to the right date then use the get method to get the day of the week.
I want to be reminded about something every week every winter. Is that possible to achieve using the ical-/webcal-standard and Google Calender, Apple Calendar/iCal, Android Calender or similar?
(I searched quite extensively for which subdomain this questioned belonged to but the results were inconclusive, with a slight predominance for SO)
It's definitely possible with RFC 5545 recurrence rules.
You can create a WEEKLY RRULE that recurs in specific months only, like so:
FREQ=WEEKLY;BYDAY=MO;BYMONTH=1,2,12
The occurrences of this rule are all Mondays in January, February and December.
Check out the first 100 instances of such an event at http://recurrence-expansion-service.appspot.com/reaas?dtstart=20160104&rrule=FREQ%3DWEEKLY%3BBYDAY%3DMO%3BBYMONTH%3D1%2C2%2C12&skip=&max_instances=100&expansion_window_end=21000104&rfc2445=1
Changing the rule to DAILY would yield the same results, but might be more compatible with actual implementations.
However, I think most calendar UIs don't provide this level of control over recurrence rules.
update:
To create an all day event starting on Dec 15 2015 and recur on the same day of week use:
DTSTART;VALUE=DATE:20151215
RRULE:FREQ=WEEKLY;BYMONTH=1,2,12
The rule doesn't include March itself. To include March just append ,3 to the rule.
I am coding little calendar program in c.
I have issue to get first day of week in current locale, i need it to format calendar. For example Sunday - is first day of week in US, but in Europe first day of week is Monday. How can i get this information for current locale? Thank you.
You can create a config file containing a map of locale and first day of the week. Read this config file and create a look up table at the beginning of the program. Refer to this table everytime you are trying to get the first day of the week for a particular locale.