Prevent year 2038 problem in ChatMember

This patch changes the Type of `{Restricted,Kicked}::until_date` fields:
`i32` => `i64`.

This is done to fix so called "year 2038 problem"
(See <https://en.wikipedia.org/wiki/Year_2038_problem>).
This commit is contained in:
Waffle 2021-03-29 10:20:03 +03:00
parent 3522a23289
commit 23cf363271
2 changed files with 4 additions and 3 deletions

View file

@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `GetChatAdministrators` output type `ChatMember` => `Vec<ChatMember>` ([#73][pr73])
- `reqwest` dependency bringing `native-tls` in even when `rustls` was selected ([#71][pr71])
- Type of `{Restricted,Kicked}::until_date` fields: `i32` => `i64` ([#74][pr74])
[pr71]: https://github.com/teloxide/teloxide-core/pull/71
[pr73]: https://github.com/teloxide/teloxide-core/pull/73

View file

@ -104,7 +104,7 @@ pub struct Administrator {
pub struct Restricted {
/// Date when restrictions will be lifted for
/// this user, unix time.
pub until_date: i32,
pub until_date: i64,
/// `true`, if the user can send text messages,
/// contacts, locations and venues.
@ -129,7 +129,7 @@ pub struct Restricted {
pub struct Kicked {
/// Date when restrictions will be lifted for
/// this user, unix time.
pub until_date: i32,
pub until_date: i64,
}
/// This allows calling [`ChatMemberKind`]'s methods directly on [`ChatMember`]
@ -260,7 +260,7 @@ impl ChatMemberKind {
}
/// Getter for [`Restricted::until_date`] and [`Kicked::until_date`] fields.
pub fn until_date(&self) -> Option<i32> {
pub fn until_date(&self) -> Option<i64> {
match &self {
Self::Creator(_) | Self::Administrator(_) | Self::Member | Self::Left => None,
Self::Restricted(Restricted { until_date, .. })