Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aura-engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Lars Kruse
aura-engine
Commits
00f7bc87
Commit
00f7bc87
authored
5 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit.
parent
dcac58b2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/base/simpleutil.py
+70
-0
70 additions, 0 deletions
modules/base/simpleutil.py
with
70 additions
and
0 deletions
modules/base/simpleutil.py
0 → 100644
+
70
−
0
View file @
00f7bc87
#
# Aura Engine
#
# Playout Daemon for autoradio project
#
#
# Copyright (C) 2020 David Trattnig <david.trattnig@subsquare.at>
#
# This file is part of engine.
#
# engine is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# engine is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with engine. If not, see <http://www.gnu.org/licenses/>.
#
# Meta
__version__
=
'
0.0.1
'
__license__
=
"
GNU General Public License (GPL) Version 3
"
__version_info__
=
(
0
,
0
,
1
)
__author__
=
'
David Trattnig <david.trattnig@subsquare.at>
'
import
datetime
import
time
class
SimpleUtil
:
"""
A container for simple utility methods.
"""
@staticmethod
def
fmt_time
(
timestamp
):
"""
Formats a UNIX timestamp to a String displaying time in the format
'
%H:%M:%S
'
.
Args:
(Integer) timestamp: Unix epoch
Returns:
(String): Displaying the time
"""
return
datetime
.
datetime
.
fromtimestamp
(
timestamp
).
strftime
(
'
%H:%M:%S
'
)
@staticmethod
def
timestamp
(
date_and_time
=
datetime
.
datetime
.
now
()):
"""
Transforms the given `datetime` into a UNIX epoch timestamp.
If no parameter is passed, the current timestamp is returned.
Args:
(Datetime) date_and_time: the date and time to transform.
Returns:
(Integer): timestamp in seconds.
"""
return
time
.
mktime
(
date_and_time
.
timetuple
())
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