Skip to content

Commit c218c05

Browse files
committed
fix: get_chat_msgs_ex(): Report local midnight in ChatItem::DayMarker
We were reporting the UTC midnight timestamp instead. For UTC-N timezones that means reporting "yesterday". Fixes deltachat/deltachat-desktop#5215.
1 parent db247d9 commit c218c05

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

deltachat-ffi/deltachat.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,12 +1332,14 @@ dc_msg_t* dc_get_draft (dc_context_t* context, uint32_t ch
13321332
* Optionally, some special markers added to the ID array may help to
13331333
* implement virtual lists.
13341334
*
1335+
* To get the concrete time of the message, use dc_array_get_timestamp().
1336+
*
13351337
* @memberof dc_context_t
13361338
* @param context The context object as returned from dc_context_new().
13371339
* @param chat_id The chat ID of which the messages IDs should be queried.
13381340
* @param flags If set to DC_GCM_ADDDAYMARKER, the marker DC_MSG_ID_DAYMARKER will
13391341
* be added before each day (regarding the local timezone). Set this to 0 if you do not want this behaviour.
1340-
* To get the concrete time of the marker, use dc_array_get_timestamp().
1342+
* The day marker timestamp is the midnight one for the corresponding (following) day in the local timezone.
13411343
* If set to DC_GCM_INFO_ONLY, only system messages will be returned, can be combined with DC_GCM_ADDDAYMARKER.
13421344
* @param marker1before Deprecated, set this to 0.
13431345
* @return Array of message IDs, must be dc_array_unref()'d when no longer used.

deltachat-jsonrpc/src/api.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,8 +1227,10 @@ impl CommandApi {
12271227
}
12281228

12291229
/// Returns all messages of a particular chat.
1230-
/// If `add_daymarker` is `true`, it will return them as
1231-
/// `DC_MSG_ID_DAYMARKER`, e.g. [1234, 1237, 9, 1239].
1230+
///
1231+
/// * `add_daymarker` - If `true`, add day markers as `DC_MSG_ID_DAYMARKER` to the result,
1232+
/// e.g. [1234, 1237, 9, 1239]. The day marker timestamp is the midnight one for the
1233+
/// corresponding (following) day in the local timezone.
12321234
async fn get_message_ids(
12331235
&self,
12341236
account_id: u32,

src/chat.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3323,10 +3323,11 @@ pub async fn get_chat_msgs_ex(
33233323
for (ts, curr_id) in sorted_rows {
33243324
if add_daymarker {
33253325
let curr_local_timestamp = ts + cnv_to_local;
3326-
let curr_day = curr_local_timestamp / 86400;
3326+
let secs_in_day = 86400;
3327+
let curr_day = curr_local_timestamp / secs_in_day;
33273328
if curr_day != last_day {
33283329
ret.push(ChatItem::DayMarker {
3329-
timestamp: curr_day * 86400, // Convert day back to Unix timestamp
3330+
timestamp: curr_day * secs_in_day - cnv_to_local,
33303331
});
33313332
last_day = curr_day;
33323333
}

0 commit comments

Comments
 (0)