date and time in udpate is fixed

This commit is contained in:
José Salazar
2026-01-28 15:02:11 -05:00
parent f8e44595c2
commit 01f1c1086f

View File

@@ -948,7 +948,17 @@ class _OrderEditSheetState extends State<_OrderEditSheet> {
}
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 nanos = (millis % 1000) * 1000000;
return Timestamp(nanos, seconds);
@@ -1071,17 +1081,23 @@ class _OrderEditSheetState extends State<_OrderEditSheet> {
.execute();
}
final DateTime orderDateOnly = DateTime.utc(
orderDate.year,
orderDate.month,
orderDate.day,
);
await _dataConnect
.updateOrder(id: widget.order.orderId)
.vendorId(_selectedVendor?.id)
.location(location)
.date(_toTimestamp(orderDate))
.date(_toTimestamp(orderDateOnly))
.execute();
await _dataConnect
.updateShift(id: _shiftId!)
.title('shift 1 ${DateFormat('yyyy-MM-dd').format(orderDate)}')
.date(_toTimestamp(orderDate))
.date(_toTimestamp(orderDateOnly))
.location(location)
.locationAddress(location)
.workersNeeded(totalWorkers)
@@ -1370,7 +1386,19 @@ class _OrderEditSheetState extends State<_OrderEditSheet> {
child: _buildInlineTimeInput(
label: 'Start',
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),
@@ -1378,7 +1406,19 @@ class _OrderEditSheetState extends State<_OrderEditSheet> {
child: _buildInlineTimeInput(
label: 'End',
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),