solving problem with dates and time in create order one time
This commit is contained in:
@@ -62,7 +62,12 @@ class ClientCreateOrderRepositoryImpl
|
||||
throw Exception('Vendor is missing.');
|
||||
}
|
||||
|
||||
final fdc.Timestamp orderTimestamp = _toTimestamp(order.date);
|
||||
final DateTime orderDateOnly = DateTime(
|
||||
order.date.year,
|
||||
order.date.month,
|
||||
order.date.day,
|
||||
);
|
||||
final fdc.Timestamp orderTimestamp = _toTimestamp(orderDateOnly);
|
||||
final fdc.OperationResult<dc.CreateOrderData, dc.CreateOrderVariables> orderResult = await _dataConnect
|
||||
.createOrder(businessId: businessId, orderType: dc.OrderType.ONE_TIME)
|
||||
.vendorId(vendorId)
|
||||
@@ -109,6 +114,10 @@ class ClientCreateOrderRepositoryImpl
|
||||
final double rate = order.roleRates[position.role] ?? 0;
|
||||
final double totalValue = rate * hours * position.count;
|
||||
|
||||
print(
|
||||
'CreateOneTimeOrder shiftRole: start=${start.toIso8601String()} end=${normalizedEnd.toIso8601String()}',
|
||||
);
|
||||
|
||||
await _dataConnect
|
||||
.createShiftRole(
|
||||
shiftId: shiftId,
|
||||
@@ -182,7 +191,17 @@ class ClientCreateOrderRepositoryImpl
|
||||
}
|
||||
|
||||
fdc.Timestamp _toTimestamp(DateTime dateTime) {
|
||||
final DateTime utc = dateTime.toUtc();
|
||||
// Keep the selected local time as-is by treating it as UTC.
|
||||
final DateTime utc = DateTime.utc(
|
||||
dateTime.year,
|
||||
dateTime.month,
|
||||
dateTime.day,
|
||||
dateTime.hour,
|
||||
dateTime.minute,
|
||||
dateTime.second,
|
||||
dateTime.millisecond,
|
||||
dateTime.microsecond,
|
||||
);
|
||||
final int seconds = utc.millisecondsSinceEpoch ~/ 1000;
|
||||
final int nanoseconds = (utc.microsecondsSinceEpoch % 1000000) * 1000;
|
||||
return fdc.Timestamp(nanoseconds, seconds);
|
||||
|
||||
Reference in New Issue
Block a user