captcha stats

This commit is contained in:
realaravinth
2021-07-27 15:28:21 +05:30
parent 9bc11f3518
commit 1d759fcb25
18 changed files with 249 additions and 159 deletions

View File

@@ -14,12 +14,23 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use std::fmt::Debug;
use sqlx::types::time::OffsetDateTime;
#[derive(Clone)]
pub struct Date {
pub time: OffsetDateTime,
}
impl Debug for Date {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Date")
.field("time", &self.print_date())
.finish()
}
}
pub const MINUTE: i64 = 60;
pub const HOUR: i64 = MINUTE * 60;
pub const DAY: i64 = HOUR * 24;
@@ -45,9 +56,15 @@ impl Date {
}
}
/// print relative time from date
pub fn print_date(&self) -> String {
Self::format(&self.time)
}
/// print date
pub fn date(&self) -> String {
self.time.format("%F %r %z")
}
}
#[cfg(test)]