Hi, I’m working as an app developer. Our team recently discovered what is likely a bug, to our knowledge it only affects the Samsung S23 Ultra.
It took us a while to figure out the issue, as the problem wasn’t possible to recreate on our devices, and only showed up on the user’s app (and the web version of the app, only on their device). We were finally able to find the line that was causing the issue using browser stack:
const now = new Date();
const start = format(startOfMonth(now), "yyyy-MM-dd");
const end = format(endOfMonth(now), "yyyy-MM-dd");
const { data, loading, error } = useGetMonthConsumptionQuery({
variables: {
from: start,
to: end,
},
});
const filteredConsumption = data?.consumption?.find(
(c: any) => format(new Date(c.from), "MM") === format(new Date(), "MM") // <-- Here lies the problem
);
The line is supposed to fetch the user’s consumption during the most recent month, the date library used here is date-fns. On any other device this works just fine, but for the S23 Ultra it returns undefined
.
The reason is that new Date(c.from)
(c being consumption, ‘from’ being when it starts from so the very start of the month) returns the first second of the first day of the month for most devices, but for S23 Ultra it misses with an hour or so, returning the last hour of the previous month. Our suspicion is that it doesn’t account for the Daylight saving time.
Adding a day to new Date(c.from)
fixed the issue for us, but we don’t think it should be neccessary. Has anyone else experienced the same problem?
Edit: FYI: adding locale to format does not help