# # 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()) @staticmethod def strike(text): """ Creates a strikethrough version of the given text. Args: (String) text: the text to strike. Returns: (String): the striked text. """ result = "" for c in text: result += c + '\u0336' return result