getLocalDayOfWeek static method

String getLocalDayOfWeek(
  1. int utcTimestampMillis,
  2. int timezoneOffsetSeconds
)

Returns local day of week string with adjusted index: "0 - Sunday", etc.

Implementation

static String getLocalDayOfWeek(int utcTimestampMillis, int timezoneOffsetSeconds) {
  final localDate = DateTime.fromMillisecondsSinceEpoch(
    utcTimestampMillis + timezoneOffsetSeconds * 1000,
    isUtc: true,
  );
  // Dart weekday: Monday = 1 ... Sunday = 7
  // Adjust so Sunday = 0, Monday = 1, ...
  int adjustedDay = (localDate.weekday % 7); // Sunday=0, Monday=1, ...
  return '$adjustedDay - ${dayOfWeek[adjustedDay]}';
}