feat: use user local timezone (#2407)

This commit is contained in:
Nathan.fooo
2023-05-03 11:50:02 +08:00
committed by GitHub
parent c4ff1a6290
commit 8cacfb1d07
3 changed files with 21 additions and 16 deletions

View File

@ -341,9 +341,10 @@ class RowDataBuilder {
_cellDataByFieldId[fieldInfo.field.id] = num.toString();
}
/// The date should use the UTC timezone. Becuase the backend uses UTC timezone to format the time string.
void insertDate(FieldInfo fieldInfo, DateTime date) {
assert(fieldInfo.fieldType == FieldType.DateTime);
final timestamp = (date.millisecondsSinceEpoch ~/ 1000);
final timestamp = (date.toUtc().millisecondsSinceEpoch ~/ 1000);
_cellDataByFieldId[fieldInfo.field.id] = timestamp.toString();
}

View File

@ -240,6 +240,8 @@ class CalendarBloc extends Bloc<CalendarEvent, CalendarState> {
cellId: cellId,
);
// The timestamp is using UTC in the backend, so we need to convert it
// to local time.
final date = DateTime.fromMillisecondsSinceEpoch(
eventPB.timestamp.toInt() * 1000,
);