# Path: pytrainer/platform.py
# def get_platform():
#     if os.name == "posix":
#         return _Linux() #although not true, not changing original return name to avoid side effects
#     elif os.name == "nt":
#         return _Windows()
#     else:
#         logging.critical("Unsupported os.name: %s.", os.name)
#         sys.exit(1)
# 
# Path: pytrainer/lib/localization.py
# def locale_str(string):
#     if sys.version_info[0] == 2:
#         lcname, encoding=locale.getlocale()
#         return string.decode(encoding)
#     else:
#         return string


import time
import datetime
import calendar
import dateutil.parser
import logging
from dateutil.tz import tzutc, tzlocal
from pytrainer.platform import get_platform
from pytrainer.lib.localization import locale_str
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.



def second2time(seconds):
    if not seconds:
        return 0,0,0
    hours = seconds // (60*60)
    seconds %= (60*60)
    minutes = seconds // 60
    seconds %= 60
    return hours,minutes,seconds

def time2second(time):
    hour,min,sec = time
    return int(sec)+(int(min)*60)+(int(hour)*3600)

def getLocalTZ():
    ''' Returns string representation of local timezone'''
    return datetime.datetime.now(tzlocal()).tzname()

def time2string(date):
    return "%0.4d-%0.2d-%0.2d" %(int(date[0]),int(date[1]),int(date[2]))

def getNameMonth(date):
    day, daysInMonth = calendar.monthrange(date.year, date.month)

# Path: pytrainer/platform.py
# def get_platform():
#     if os.name == "posix":
#         return _Linux() #although not true, not changing original return name to avoid side effects
#     elif os.name == "nt":
#         return _Windows()
#     else:
#         logging.critical("Unsupported os.name: %s.", os.name)
#         sys.exit(1)
# 
# Path: pytrainer/lib/localization.py
# def locale_str(string):
#     if sys.version_info[0] == 2:
#         lcname, encoding=locale.getlocale()
#         return string.decode(encoding)
#     else:
#         return string


# Path: pytrainer/lib/date.py
import time
import datetime
import calendar
import dateutil.parser
import logging
from dateutil.tz import tzutc, tzlocal
from pytrainer.platform import get_platform
from pytrainer.lib.localization import locale_str

#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.



def second2time(seconds):
    if not seconds:
        return 0,0,0
    hours = seconds // (60*60)
    seconds %= (60*60)
    minutes = seconds // 60
    seconds %= 60
    return hours,minutes,seconds

def time2second(time):
    hour,min,sec = time
    return int(sec)+(int(min)*60)+(int(hour)*3600)

def getLocalTZ():
    ''' Returns string representation of local timezone'''
    return datetime.datetime.now(tzlocal()).tzname()

def time2string(date):
    return "%0.4d-%0.2d-%0.2d" %(int(date[0]),int(date[1]),int(date[2]))

def getNameMonth(date):
    day, daysInMonth = calendar.monthrange(date.year, date.month)

    monthName = locale_str(calendar.month_name[date.month])