Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

timezone.py 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. """
  2. """
  3. # Created on 2015.01.07
  4. #
  5. # Author: Giovanni Cannata
  6. #
  7. # Copyright 2015 - 2018 Giovanni Cannata
  8. #
  9. # This file is part of ldap3.
  10. #
  11. # ldap3 is free software: you can redistribute it and/or modify
  12. # it under the terms of the GNU Lesser General Public License as published
  13. # by the Free Software Foundation, either version 3 of the License, or
  14. # (at your option) any later version.
  15. #
  16. # ldap3 is distributed in the hope that it will be useful,
  17. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. # GNU Lesser General Public License for more details.
  20. #
  21. # You should have received a copy of the GNU Lesser General Public License
  22. # along with ldap3 in the COPYING and COPYING.LESSER files.
  23. # If not, see <http://www.gnu.org/licenses/>.
  24. from datetime import timedelta, tzinfo
  25. # from python standard library docs
  26. class OffsetTzInfo(tzinfo):
  27. """Fixed offset in minutes east from UTC"""
  28. def __init__(self, offset, name):
  29. self.offset = offset
  30. self.name = name
  31. self._offset = timedelta(minutes=offset)
  32. def __str__(self):
  33. return self.name
  34. def __repr__(self):
  35. return 'OffsetTzInfo(offset={0.offset!r}, name={0.name!r})'.format(self)
  36. def utcoffset(self, dt):
  37. return self._offset
  38. def tzname(self, dt):
  39. return self.name
  40. # noinspection PyMethodMayBeStatic
  41. def dst(self, dt):
  42. return timedelta(0)
  43. def __getinitargs__(self): # for pickling/unpickling
  44. return self.offset, self.name