Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion QDateInlineTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ - (void)prepareDateTimePicker:(QDateTimeInlineElement *)element
if (!self.pickerView)
self.pickerView = [[UIDatePicker alloc] init];

self.pickerView.timeZone = [NSTimeZone localTimeZone];
self.pickerView.timeZone = element.timeZone ? element.timeZone : [NSTimeZone localTimeZone];
[self.pickerView sizeToFit];
self.pickerView.datePickerMode = element.mode;
self.pickerView.maximumDate = element.maximumDate;
Expand All @@ -64,6 +64,7 @@ - (void) dateChanged:(id)sender{
- (void)prepareForElement:(QDateTimeInlineElement *)element inTableView:(QuickDialogTableView *)tableView {

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.timeZone = element.timeZone ? element.timeZone : [NSTimeZone localTimeZone];

self.element = element;
if (element.customDateFormat!=nil){
Expand Down
3 changes: 2 additions & 1 deletion quickdialog/QDateEntryTableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ - (void)prepareDateTimePicker:(QDateTimeInlineElement * const)element
if (!_pickerView)
_pickerView = [[UIDatePicker alloc] init];

_pickerView.timeZone = [NSTimeZone localTimeZone];
_pickerView.timeZone = element.timeZone ? element.timeZone : [NSTimeZone localTimeZone];
[_pickerView sizeToFit];
[_pickerView addTarget:self action:@selector(dateChanged:) forControlEvents:UIControlEventValueChanged];
_pickerView.datePickerMode = element.mode;
Expand Down Expand Up @@ -100,6 +100,7 @@ - (void)prepareForElement:(QEntryElement *)element inTableView:(QuickDialogTable
QDateTimeInlineElement *dateElement = ((QDateTimeInlineElement *) element);

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.timeZone = dateElement.timeZone ? dateElement.timeZone : [NSTimeZone localTimeZone];

if (element.customDateFormat!=nil){
dateFormatter.dateFormat = element.customDateFormat;
Expand Down
2 changes: 2 additions & 0 deletions quickdialog/QDateTimeInlineElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

@property(nonatomic, strong) NSDate *minimumDate;

@property (nonatomic, strong) NSTimeZone *timeZone;

@property(nonatomic) BOOL showPickerInCell;

- (QDateTimeInlineElement *)initWithDate:(NSDate *)date andMode:(UIDatePickerMode)mode;
Expand Down
3 changes: 3 additions & 0 deletions quickdialog/QDateTimeInlineElement.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ @implementation QDateTimeInlineElement {
@private
NSDate *_maximumDate;
NSDate *_minimumDate;
NSTimeZone *_timeZone;

__weak QTableViewCell *_cell;
}
Expand All @@ -26,6 +27,7 @@ @implementation QDateTimeInlineElement {
@synthesize centerLabel = _centerLabel;
@synthesize maximumDate = _maximumDate;
@synthesize minimumDate = _minimumDate;
@synthesize timeZone = _timeZone;
@synthesize onValueChanged = _onValueChanged;
@synthesize minuteInterval = _minuteInterval;

Expand Down Expand Up @@ -67,6 +69,7 @@ - (NSDate *)dateValue
{
if (self.mode == UIDatePickerModeDate) {
NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
gregorian.timeZone = self.timeZone ? self.timeZone : [NSTimeZone localTimeZone];
NSDateComponents *dateComponents = [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:_dateValue];
_dateValue = [gregorian dateFromComponents:dateComponents];
}
Expand Down
23 changes: 14 additions & 9 deletions sample/SampleDataBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,11 @@ + (QRootElement *)createDateTimeRoot {

QDateTimeInlineElement *el4 = [[QDateTimeInlineElement alloc] initWithTitle:@"Time only" date:[NSDate date] andMode:UIDatePickerModeTime];
[section addElement:el4];

QDateTimeInlineElement *el5 = [[QDateTimeInlineElement alloc] initWithTitle:@"Time only (UTC)" date:[NSDate date] andMode:UIDatePickerModeTime];
el5.timeZone = [NSTimeZone timeZoneWithName:@"UTC"];
[section addElement:el5];


QDateTimeInlineElement *elDiffTime = [[QDateTimeInlineElement alloc] initWithTitle:@"Different date" date:
[NSDate dateWithTimeIntervalSinceNow:-36000] andMode:UIDatePickerModeDate];
Expand All @@ -672,19 +677,19 @@ + (QRootElement *)createDateTimeRoot {
QSection *section2 = [[QSection alloc] init];
section2.title = @"Push editing";

QDateTimeElement *el5 = [[QDateTimeElement alloc] initWithTitle:@"Time only" date:[NSDate date]];
el5.mode = UIDatePickerModeTime;
[section2 addElement:el5];

QDateTimeElement *el6 = [[QDateTimeElement alloc] initWithTitle:@"Date only" date:[NSDate date]];
el6.mode = UIDatePickerModeDate;
QDateTimeElement *el6 = [[QDateTimeElement alloc] initWithTitle:@"Time only" date:[NSDate date]];
el6.mode = UIDatePickerModeTime;
[section2 addElement:el6];

QDateTimeElement *el7 = [[QDateTimeElement alloc] initWithTitle:@"Full Date" date:[NSDate date]];
el7.mode = UIDatePickerModeDateAndTime;
el7.minuteInterval = 3;
QDateTimeElement *el7 = [[QDateTimeElement alloc] initWithTitle:@"Date only" date:[NSDate date]];
el7.mode = UIDatePickerModeDate;
[section2 addElement:el7];

QDateTimeElement *el8 = [[QDateTimeElement alloc] initWithTitle:@"Full Date" date:[NSDate date]];
el8.mode = UIDatePickerModeDateAndTime;
el8.minuteInterval = 3;
[section2 addElement:el8];

[root addSection:section];
[root addSection:section2];
return root;
Expand Down