Skip to content

Commit 203db87

Browse files
committed
Copy date entities to clipboard
1 parent 95f7c93 commit 203db87

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

‎Telegram/Common/MessageHelper.cs‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,35 @@ public static async void CopyText(XamlRoot xamlRoot, FormattedText text)
208208
writer.WriteByte(12);
209209
writer.WriteInt64(mentionName.UserId);
210210
break;
211+
case TextEntityTypeDate date:
212+
writer.WriteByte(13);
213+
writer.WriteInt32(date.Date);
214+
if (date.FormattingType is DateFormattingTypeAbsolute absolute)
215+
{
216+
writer.WriteByte(1);
217+
writer.WriteByte(absolute.DayPrecision switch
218+
{
219+
DatePartPrecisionLong => 1,
220+
DatePartPrecisionShort => 2,
221+
_ => 0
222+
});
223+
writer.WriteByte(absolute.TimePrecision switch
224+
{
225+
DatePartPrecisionLong => 1,
226+
DatePartPrecisionShort => 2,
227+
_ => 0
228+
});
229+
writer.WriteBoolean(absolute.ShowDayOfWeek);
230+
}
231+
else if (date.FormattingType is DateFormattingTypeRelative)
232+
{
233+
writer.WriteByte(2);
234+
}
235+
else
236+
{
237+
writer.WriteByte(0);
238+
}
239+
break;
211240
}
212241
}
213242

@@ -339,6 +368,24 @@ public static async Task<FormattedText> PasteTextAsync(DataPackageView package)
339368
case 12:
340369
entity.Type = new TextEntityTypeMentionName(reader.ReadInt64());
341370
break;
371+
case 13:
372+
entity.Type = new TextEntityTypeDate(reader.ReadInt32(), reader.ReadByte() switch
373+
{
374+
1 => new DateFormattingTypeAbsolute(reader.ReadByte() switch
375+
{
376+
1 => new DatePartPrecisionLong(),
377+
2 => new DatePartPrecisionShort(),
378+
_ => new DatePartPrecisionNone()
379+
}, reader.ReadByte() switch
380+
{
381+
1 => new DatePartPrecisionLong(),
382+
2 => new DatePartPrecisionShort(),
383+
_ => new DatePartPrecisionNone()
384+
}, reader.ReadBoolean()),
385+
2 => new DateFormattingTypeRelative(),
386+
_ => null
387+
});
388+
break;
342389
}
343390

344391
entities.Add(entity);

0 commit comments

Comments
 (0)