diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index 944905e..a44a894 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -580,9 +580,54 @@ class Client::JsonEntity final : public td::Jsonable { case td_api::textEntityTypeExpandableBlockQuote::ID: object("type", "expandable_blockquote"); break; - case td_api::textEntityTypeDateTime::ID: + case td_api::textEntityTypeDateTime::ID: { + auto entity = static_cast(entity_->type_.get()); object("type", "date_time"); + object("unix_time", entity->unix_time_); + td::string format; + if (entity->formatting_type_ != nullptr) { + switch (entity->formatting_type_->get_id()) { + case td_api::dateTimeFormattingTypeRelative::ID: + format = "r"; + break; + case td_api::dateTimeFormattingTypeAbsolute::ID: { + auto abs = static_cast(entity->formatting_type_.get()); + if (abs->show_day_of_week_) { + format += 'w'; + } + switch (abs->date_precision_->get_id()) { + case td_api::dateTimePartPrecisionNone::ID: + break; + case td_api::dateTimePartPrecisionShort::ID: + format += 'd'; + break; + case td_api::dateTimePartPrecisionLong::ID: + format += 'D'; + break; + default: + UNREACHABLE(); + } + switch (abs->time_precision_->get_id()) { + case td_api::dateTimePartPrecisionNone::ID: + break; + case td_api::dateTimePartPrecisionShort::ID: + format += 't'; + break; + case td_api::dateTimePartPrecisionLong::ID: + format += 'T'; + break; + default: + UNREACHABLE(); + } + break; + } + default: + UNREACHABLE(); + } + } + object("date_time_format", format); break; + } default: UNREACHABLE(); }