QML Calendar: change first day of week - calendar

Is there any way to change the first day of the week on QML Calendar?
Not only Monday/Sunday, but also for any day of the week.
I found a workaround for Monday/Sunday; force Qt.locale() for a country which has Monday or Sunday specified as first day of the week, but it is not extended to the rest of the days. Thanks in advance!

Related

How to get first of week based calendar in nodatime?

I want to get first day of week for specificid ZonedDateTime in NodaTime.
But week starts Saturday in Persian calendar and Monday in Gregorian calendar.
How can I get first day of week based on calendar of ZonedDateTime?
We don't expose that information, because it's not as cut and dried as you expect it to be. Different cultures and contexts use different week rules - for example, while you've stated that the week starts on Monday in the Gregorian calendar, that's context specific. In many contexts Sunday is used as the first day of the week instead.
See the week numbering part of the Wikipedia article on weeks for examples of this.
It sounds like you'll probably want a Dictionary<CalendarSystem, IsoDayOfWeek> or possibly a Dictionary<CalendarSystem, IWeekYearRule> in your application, depending on what you're trying to achieve.

Event every 5th day of mont (or 4th/3rd if it's weekend or holiday) using iCal

In Brazil my payday happen on every 5th day of month.
But if the 5th day is a saturday/sunday, then the payment will happen on the 4th day.
Same if 4th is saturday/sunday: then the payment will happen on 3rd day. And so on.
Is there any way to create a event that will work with Google Calendar and iCal?
You can achieve that with iCalendar, at least as far as it concerns weekends.
Consider the following rule:
DTSTART;TZID=US-Eastern:20160505T000000
RRULE:FREQ=MONTHLY;BYMONTHDAY=1,2,3,4,5;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1
The rule is evaluated as follows:
FREQ=MONTHLY;BYMONTHDAY=1,2,3,4,5: expand to the 1st, 2nd, 3rd, 4th and 5th day of each month
BYDAY=MO,TU,WE,TH,FR: filter by week day, retain only work days/remove weekend days
BYSETPOS=-1: retain only the last day of the set
You can verify the result at http://recurrence-expansion-service.appspot.com/
Here are the first 100 instances.
It's not possible to achieve that for holidays though.
Update:
It's actually sufficient to specify
RRULE:FREQ=MONTHLY;BYMONTHDAY=3,4,5;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1
Since the weekend is at most 2 days long, payday must fall on one of the 3rd, 4th or 5th day of the month. Again, this does not take holidays into account.
Holidays always need special consideration. Not only does RRULE not support this kind of logic for arbitrary days, sometimes it's difficult or even impossible to express holidays by an RRULE themselves. In some countries certain holidays are always on a specific day, except when the days falls on a weekend, in which case the holiday is on the Friday before or the Monday after the weekend. Or consider the Easter date and holidays relative to the Easter date, they can't be expressed by an RRULE at all.
Not to forget that some holidays may change every now and then (like "King's days" or "Queen's days" in certain countries).
The best you can do is to manage these manually and add an RDATE and an EXDATE if payday would fall on a holiday according to the RRULE above.

SSRS Date Expression stopped working

I hope someone can share their experience with me. I've used the following ssrs expression to default a SSRS report parameter to the last day of the current month for months without issue:
=DateAdd(ā€œdā€, -1, DateSerial(Year(Now()), Month(Now()), 1))
This morning instead of returnng 3/31/2016, the expression is stuck on 3/29/2016. Can anyone help me understand why this happened?
You are substracting one day to the first day of the current month.
You have to get the first day of the next month and substract one day.
=DateAdd("d", -1, DateSerial(2016, Month(Now.AddMonths(1)), 1))
It returns 3/31/2016
Let me know if this helps.
The expression you show will give the last day of the previous month, not the last day of this month.
You want to do date arithmetic rather than build dates from scratch. Think about what will happen in December if you are using the current year but adding a month to find the month you need.
The safest way to get the last day of the current month would be to calculate the first day of this month, add one month then subtract a day:
=DateAdd(DateInterval.Day, -1, DateAdd(DateInterval.Month, 1, DateAdd(DateInterval.Day, 1-Day(Today), Today)))
If what you actually want is the last day of the previous month, then that is simple:
=DateAdd(DateInterval.Day, 0-Day(Today), Today)

How to get first day of week in c

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.

how do we get the first and last day of the current month

How do we get the first day of the month and last day of the month. i am using it on a apex class.
i can get the todays date by using
date.today()
but how would i get the first and last day of the month.
Thanks
You should get familiar with the Apex Code Developers Guide as it has very good documentation for questions like this. Here's the Date methods page that you would find helpful.
With respect to your specific question, you get the first date of the month (I'll use today's month in my example) using the following
Date firstDayOfMonth = System.today().toStartOfMonth();
To get the last day of the month, use the following:
Date lastDayOfMonth = firstDayOfMonth.addDays(Date.daysInMonth(firstDayOfMonth.year(), firstDayOfMonth.month()) - 1);
I think there is a better way to solve the second problem, that is, accept the last day of the month.
firstDayOfMonth.addMonths(1).addDays(-1);

Resources