Cannot update calendar firstWeekDay Swift 3.0 - ios

I'm trying to update the calendar firstWeekDay to something else (as far as I seen the default firstWeekDay is Sunday) but some errors occur.
private var calendar = Calendar.autoupdatingCurrent
calendar.firstWeekday = 3
// the 2nd line is here only to ask this question on StackOverFlow (is missing on my code because I am want the user to use its own calendar, not something forced by me.
Check code+errors screenshot here
Note: I managed to do this at the beginning of the project with the same simple code but after a while I updated the app on my personal iPhone to check how it looks and behave on a real device and I noticed that the the first week day is not Monday anymore as my personal iPhone calendar is set.

I managed to solve the issue. Apparently I had to define a new function and update the firstWeekDay property inside that function. :)

Related

How to use Dart's Difference Method and DateTime using a dynamic date?

The application I'm building uses a sort of "Days since" counter using Duration Difference and DateTime, but I want the counter to begin on the day they started using the app by default, and have the option to put in whichever date they desire.
My Question is, how do i dynamically generate the start date of the counter to be the day they start using the app, and would this be easiest achieved with a database?
Ok, so from my point of view a good way to do it seems to use shared_preferences. Shared preferences allow to store some key/value pair for the user, it's persistent and you can update it.
Here's the package: https://pub.dartlang.org/packages/shared_preferences
Here's a good article giving you details about it : https://www.didierboelens.com/2018/04/shared-preferences---how-to-save-flutter-application-settings-and-user-preferences-for-later-re-use/
The idea would be to create a function, checking if the key of first_use_date exists.
If it does do nothing (or you can actually update it)
If not you create it with the date of today.
Of course it's persistent since the app stays installed on the device.
For printing duration I let you check this class : https://docs.flutter.io/flutter/intl/DateFormat-class.html
And especially this method (which is not implemented yet) : https://docs.flutter.io/flutter/intl/DateFormat/formatDurationFrom.html
Hope it's helps !!

Any way to have UIDatePicker pick dates earlier than 1/1/1 AD/CE?

I'm pretty sure the answer must be no, since if I set its minimumDate to an earlier date, it still stops rolling back at 1 AD. Also if I set its start date to a BC/BCE date it goes to 1/1/1. I'm just hoping there is some secret trick someone might know.
Only by using a custom UIPickerView to do what you want I'm afraid...

Assigning a custom date with custom label to a contact

I have an app that from some reason needs to assign a custom date to the user contacts, The app was out and worked fine. Now I wish to build a swift version of the app.
While testing it on xCode 6, iOS7 + 8 everything looks great, but when testing in a device I see that the date is added as the Anniversary date of the user and without my custom label.
I tried to add the date directly in the native Contacts app and found that new contacts does not have an option to add a custom date.
Testing on Yosemite I still find this option available.
When checking the ABPerson API I found that the API still has the kABMultiDatePropertyType
// Dates
AB_EXTERN const ABPropertyID kABPersonDateProperty;
// Dates associated with this person - kABMultiDatePropertyType
It is important to note that when saving the new date I do not get any Error and the date is saved but without my custom label which is important as I do not want to override the user Anniversary date.
Any idea why this is happening / any workaround ?

JQuery UI / Datepicker : How to initialize datepicker with an empty year?

My problem is the following :
On my website, I use the Jquery-ui datepicker to allow my visitor to enter a date.
I have configured the datepicker such users can modify the month and the year.
However, I have noticed that they never enter the year : they leave in the default value.
In my mind, they don't see that they can edit the year value...
So, I would like to intialize the default year value to empty/blank and show an error alert if the user has not modified it.
I try to do that, but in vain....
So how can I do that ?
Maybe, there is an other way to force my users to select a correct year value. Have you got any suggestions ?
In advance, thanks for your answer.
I thought a little bit and I think what I would do is not possible...
How could the datpicker calculate the days of the month if the year is not specified?
So, Have you got any suggestions to force my users to change the year default value ?
You could identify what the default value is and then, in your onSelect callback you could see if the current year value is different than what the original was and execute whatever code seems appropriate.

Select Active Tab By Date

This question was posed about selecting the active tab by weekday https://stackoverflow.com/a/7681679/1339863.
I'm sure this can be done for the month as well, but I have searched and haven't been able to find the proper application. I'm so new to jquery I can't figure out how to alter the code to suit my needs. Please Help!
you can adapt the previous code in the stackoverflow archive, just you need to extract months from date, use this code:
var date = new Date();
var months = date.getMonth();

Resources