Skip to content
Snippets Groups Projects
Forked from DM / dm-docs
261 commits behind, 263 commits ahead of the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
timeUtility.py 731 B
#!/usr/bin/env python

import time
class TimeUtility:

    @classmethod
    def getCurrentGMTimeStamp(cls):
        """ Formats GMT timestamp. """
        return time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(time.time()))

    @classmethod
    def formatGMTimeStamp(cls, t):
        """ Format GMT timestamp. """
        return time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(t))

    @classmethod
    def getCurrentLocalTimeStamp(cls):
        """ Formats local timestamp. """
        return time.strftime('%Y/%m/%d %H:%M:%S %Z', time.localtime(time.time()))

    @classmethod
    def formatLocalTimeStamp(cls, t):
        """ Formats local timestamp. """
        return time.strftime('%Y/%m/%d %H:%M:%S %Z', time.localtime(t))