date and time in udpate is fixed
This commit is contained in:
@@ -948,7 +948,17 @@ class _OrderEditSheetState extends State<_OrderEditSheet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Timestamp _toTimestamp(DateTime date) {
|
Timestamp _toTimestamp(DateTime date) {
|
||||||
final int millis = date.millisecondsSinceEpoch;
|
final DateTime utc = DateTime.utc(
|
||||||
|
date.year,
|
||||||
|
date.month,
|
||||||
|
date.day,
|
||||||
|
date.hour,
|
||||||
|
date.minute,
|
||||||
|
date.second,
|
||||||
|
date.millisecond,
|
||||||
|
date.microsecond,
|
||||||
|
);
|
||||||
|
final int millis = utc.millisecondsSinceEpoch;
|
||||||
final int seconds = millis ~/ 1000;
|
final int seconds = millis ~/ 1000;
|
||||||
final int nanos = (millis % 1000) * 1000000;
|
final int nanos = (millis % 1000) * 1000000;
|
||||||
return Timestamp(nanos, seconds);
|
return Timestamp(nanos, seconds);
|
||||||
@@ -1071,17 +1081,23 @@ class _OrderEditSheetState extends State<_OrderEditSheet> {
|
|||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final DateTime orderDateOnly = DateTime.utc(
|
||||||
|
orderDate.year,
|
||||||
|
orderDate.month,
|
||||||
|
orderDate.day,
|
||||||
|
);
|
||||||
|
|
||||||
await _dataConnect
|
await _dataConnect
|
||||||
.updateOrder(id: widget.order.orderId)
|
.updateOrder(id: widget.order.orderId)
|
||||||
.vendorId(_selectedVendor?.id)
|
.vendorId(_selectedVendor?.id)
|
||||||
.location(location)
|
.location(location)
|
||||||
.date(_toTimestamp(orderDate))
|
.date(_toTimestamp(orderDateOnly))
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
await _dataConnect
|
await _dataConnect
|
||||||
.updateShift(id: _shiftId!)
|
.updateShift(id: _shiftId!)
|
||||||
.title('shift 1 ${DateFormat('yyyy-MM-dd').format(orderDate)}')
|
.title('shift 1 ${DateFormat('yyyy-MM-dd').format(orderDate)}')
|
||||||
.date(_toTimestamp(orderDate))
|
.date(_toTimestamp(orderDateOnly))
|
||||||
.location(location)
|
.location(location)
|
||||||
.locationAddress(location)
|
.locationAddress(location)
|
||||||
.workersNeeded(totalWorkers)
|
.workersNeeded(totalWorkers)
|
||||||
@@ -1370,7 +1386,19 @@ class _OrderEditSheetState extends State<_OrderEditSheet> {
|
|||||||
child: _buildInlineTimeInput(
|
child: _buildInlineTimeInput(
|
||||||
label: 'Start',
|
label: 'Start',
|
||||||
value: pos['start_time'],
|
value: pos['start_time'],
|
||||||
onTap: () {},
|
onTap: () async {
|
||||||
|
final TimeOfDay? picked = await showTimePicker(
|
||||||
|
context: context,
|
||||||
|
initialTime: TimeOfDay.now(),
|
||||||
|
);
|
||||||
|
if (picked != null && context.mounted) {
|
||||||
|
_updatePosition(
|
||||||
|
index,
|
||||||
|
'start_time',
|
||||||
|
picked.format(context),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: UiConstants.space2),
|
const SizedBox(width: UiConstants.space2),
|
||||||
@@ -1378,7 +1406,19 @@ class _OrderEditSheetState extends State<_OrderEditSheet> {
|
|||||||
child: _buildInlineTimeInput(
|
child: _buildInlineTimeInput(
|
||||||
label: 'End',
|
label: 'End',
|
||||||
value: pos['end_time'],
|
value: pos['end_time'],
|
||||||
onTap: () {},
|
onTap: () async {
|
||||||
|
final TimeOfDay? picked = await showTimePicker(
|
||||||
|
context: context,
|
||||||
|
initialTime: TimeOfDay.now(),
|
||||||
|
);
|
||||||
|
if (picked != null && context.mounted) {
|
||||||
|
_updatePosition(
|
||||||
|
index,
|
||||||
|
'end_time',
|
||||||
|
picked.format(context),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: UiConstants.space2),
|
const SizedBox(width: UiConstants.space2),
|
||||||
|
|||||||
Reference in New Issue
Block a user