Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Commits
f75b160d
Commit
f75b160d
authored
3 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
util_format: Zkrácená podoba timestampu
parent
d5c26c39
No related branches found
No related tags found
1 merge request
!86
Registrace
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
mo/util_format.py
+7
-0
7 additions, 0 deletions
mo/util_format.py
mo/web/jinja.py
+1
-0
1 addition, 0 deletions
mo/web/jinja.py
with
8 additions
and
0 deletions
mo/util_format.py
+
7
−
0
View file @
f75b160d
...
...
@@ -41,6 +41,13 @@ def timeformat(dt: datetime) -> str:
return
dt
.
astimezone
().
strftime
(
"
%Y-%m-%d %H:%M
"
)
def
timeformat_short
(
dt
:
datetime
)
->
str
:
if
dt
is
None
:
return
'
–
'
else
:
return
dt
.
astimezone
().
strftime
(
"
%Y-%m-%d
"
)
def
timedelta
(
d
:
datetime
,
ref
:
Optional
[
datetime
]
=
None
,
descriptive
:
bool
=
False
)
->
str
:
"""
Vyrábí česky formátované řetězece
'
za 3 minuty
'
,
'
před 27 dny
'
a podobně
z rozdílu daného datetime a referenčního času (například now).
...
...
This diff is collapsed.
Click to expand it.
mo/web/jinja.py
+
1
−
0
View file @
f75b160d
...
...
@@ -24,6 +24,7 @@ app.jinja_env.trim_blocks = True
# Filtry definované v mo.util_format
app
.
jinja_env
.
filters
.
update
(
timeformat
=
util_format
.
timeformat
)
app
.
jinja_env
.
filters
.
update
(
timeformat_short
=
util_format
.
timeformat_short
)
app
.
jinja_env
.
filters
.
update
(
inflected
=
util_format
.
inflect_number
)
app
.
jinja_env
.
filters
.
update
(
inflected_by
=
util_format
.
inflect_by_number
)
app
.
jinja_env
.
filters
.
update
(
timedelta
=
util_format
.
timedelta
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment