add `time` and `datetime` to `DateTimeExpressions`

This commit is contained in:
Alexander Wilde 2022-07-04 14:03:55 +01:00
parent 116f98269d
commit 8c46388563
1 changed files with 16 additions and 0 deletions

View File

@ -46,6 +46,22 @@ extension DateTimeExpressions on Expression<DateTime?> {
);
}
/// Formats this datetime in the format `hour:minute:second`.
Expression<String?> get time {
return FunctionCallExpression(
'TIME',
[this, const Constant<String>('unixepoch')],
);
}
/// Formats this datetime in the format `year-month-day hour:minute:second`.
Expression<String?> get datetime {
return FunctionCallExpression(
'DATETIME',
[this, const Constant<String>('unixepoch')],
);
}
/// Returns an expression containing the amount of seconds from the unix
/// epoch (January 1st, 1970) to `this` datetime expression. The datetime is
/// assumed to be in utc.