How can i create combine Gregorian and Islamic(Hijri) FSCalendar - ios

Can you please tell me. I changed calendar identifier like this
but it shows a warning (Changing Calendar identifier is not recommended).
_calendar.identifier = NSCalendarIdentifierIslamic;

Related

Calendar days and Time into UIDatePicker with Inline style show only in English

I have made a view with UIDatePicker in Preferred Style "Inline". I need show this calendar in Spanish, so I added Locale lines:
[_pickerCalendar setLocale:[NSLocale localeWithLocaleIdentifier:#"es"]];
_pickerCalendar.calendar.locale = [NSLocale localeWithLocaleIdentifier:#"es"];
With this, I could see that general DatePicker translated correctly but calendar and time label show English yet (see image)
I believed that it could be a iOS bug, but when I saw iOS native calendar it show Spanish correctly (see image)
I can't find which property is the correct to change language. Into Settings - General - Language and Region I hace this information:
Region: Mexico
Calendar: Gregorian
Preferred Language: Spanish
Aditional info:
iOS 14.5 (Simulator) and iOS 14.6 (Device)
Xcode 12.5
Language: Objective-C
Thanks for your help because I really need it.
UPDATE:
I implemented UIDatePicker in Swift with this code:
calendarPicker.locale = Locale(identifier: "es-MX")
calendarPicker.calendar.locale = Locale(identifier: "es-MX")
and the result was days into calendar already shows in Spanish but the label "Time" shows in English yet and not in Spanish. You can see it in the image:

XCUITest, UIDatePicker, adjustToPickerWheelValue

I'm writing an XCUITest. I have a view with a UIDatePicker on it (NOT a regular picker).
I'm trying to set the date using adjustToPickerWheelValue.
This crashes with the following error:
caught "NSInvalidArgumentException", "-[XCUIElement(XCUIElementTypePickerWheel) adjustToPickerWheelValue:]_block_invoke can only be called with elements of type XCUIElementTypePickerWheel, not valid for DatePicker."
This implies of course that this method is not available for the UIDatePicker.
I've gone through the apple site and it states pretty clearly that it IS supported.
I can't find any examples of this used for a date picker.
It's possible of course that I'm just not setting it right (I'm not sure how one would pass a string date, for example).
This is the code I'm trying:
XCUIElement *DOB;
XCUIElementQuery *DOBList = app.datePickers;
DOB = [DOBList elementBoundByIndex:0];
NSLog(#"DOB = %#\n", [DOB description]);
[DOB adjustToPickerWheelValue:#"SOME DATE GOES HERE?"];
BTW - description is of a DatePicker.
Printing [DOB value] just returns an empty string.
Any ideas?
For using UIDatePickers, I do like that:
XCUIApplication().datePickers.firstMatch.pickerWheels["CurrentValue"].adjust(toPickerWheelValue: "NewValue")
You have to do that for each picker of the UIDatePicker.

Converting Firestore Timestamp to Date data type

Few days ago, I just updated my firebase pod to the latest version, and in my debugging area, I got message that said that I have to update from timestamp data type to Date (something like that, I forget actually).
and I also have to change the DB settings like below
let db = Firestore.firestore()
let settings = db.settings
settings.areTimestampsInSnapshotsEnabled = true
db.settings = settings
after add the code above, the error message in my debugging area in Xcode disappears.
As far as I remember, I also had to change the data type in my client from Timestamp to Date data type, I haven't changed this because the error message in my debugging area in Xcode have disappeared.
As a result, I get not correct Date in my app.
Could you please share again the conversion step from TimeStamp to Date ? because as far as I remember I had to do some steps to follow. I can't find it in the firebase documentation.
Thank you very much :)
This is the message from the debugger
The behavior for system Date objects stored in Firestore is going to change AND YOUR APP MAY BREAK.
To hide this warning and ensure your app does not break, you need to add the following code to your app before calling any other Cloud Firestore methods:
let db = Firestore.firestore()
let settings = db.settings
settings.areTimestampsInSnapshotsEnabled = true
db.settings = settings
With this change, timestamps stored in Cloud Firestore will be read back as Firebase Timestamp objects instead of as system Date objects. So you will also need to update code expecting a Date to instead expect a Timestamp. For example:
// old:
let date: Date = documentSnapshot.get("created_at") as! Date
// new:
let timestamp: Timestamp = documentSnapshot.get("created_at") as! Timestamp
let date: Date = timestamp.dateValue()
Please audit all existing usages of Date when you enable the new behavior. In a future release, the behavior will be changed to the new behavior, so if you do not follow these steps, YOUR APP MAY BREAK.

How to set lunar calendar UIDatePicker in iOS

I need switch UIDatePicker between Solar calendar and Lunar calendar. With Lunar calendar, I can get 02/30/2016 (MM/dd/yyyy), but with Solar calendar, its never get 02/30/2016 (MM/dd/yyyy). So, how can set it in UIDatePicker ?
I don't think it is possible, all supported calendars can be found in Apple Documentation
Lunar Calendar is also known is Chinese Calendar. Try these
self.datePicker.locale = Locale.init(identifier: "zh")
self.datePicker.calendar = Calendar.init(identifier: .chinese)
However, I tried both in simulator and with some app, there is no 2016/02/30 in Lunar. There is 2016/2/29 which convert to 2016/4/6 in Solar. There is 2015/02/30 Lunar (see below)
However, in the date picker, it shows all the leap months even it is invalid.

SBDatePicker Its posssible to set minimum date and maximum date in swift?

I am new for developing the ios application, I have used SBPickerSelector in Cocapods framework for Selecting datePicker.
whether If possible to set the MinumDate and MaximumDate???
Try;
let picker: SBPickerSelector = SBPickerSelector.picker()
//Minimum Date
picker.datePickerView.minimumDate = NSDate(); // A date
//Maximum Date
picker.datePickerView.maximumDate = NSDate(); // An other date ;
//or picker.setMaximumDateAllowed(NSDate())
I do not understand what do you get from using SBDatePicker, it look like they simply wrap the original class UIDatePicker.
The problem of using this kind of wrappers is that they don't always have the full feature set of the original class and you count on their developers to keep up with Apple changes (which they don't).
If you simply use UIDatePicker you can set maximumDate and minimumDate, just like you asked.
Check out the UIDatePicker Class Reference
And here is an example of setting the minimum and maximum dates

Resources