Skip to content

Commit

Permalink
rename natz/ -> mytz/
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Mar 22, 2024
1 parent dbeedd1 commit 05e874d
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 24 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions plugins/pray_times_files/pray_times.py
Expand Up @@ -42,7 +42,7 @@
# if "gtk" in sys.modules:
from pray_times_gtk import TextPluginUI, showDisclaimer

import natz
import mytz
from scal3 import logger
from scal3.cal_types import hijri
from scal3.cal_types.gregorian import to_jd as gregorian_to_jd
Expand All @@ -68,7 +68,7 @@

# ----------------------------------------------------

localTz = natz.gettz()
localTz = mytz.gettz()

timeDescByName = dict(timeNames)

Expand Down
12 changes: 6 additions & 6 deletions scal3/event_lib.py
Expand Up @@ -38,7 +38,7 @@

from cachetools import LRUCache

import natz
import mytz
from scal3 import core, ics, locale_man
from scal3.cal_types import (
GREGORIAN,
Expand Down Expand Up @@ -2030,8 +2030,8 @@ def copySomeRuleTypesFrom(

def getTimeZoneObj(self):
if self.timeZoneEnable and self.timeZone:
# natz.gettz does not raise exception, returns None if invalid
tz = natz.gettz(self.timeZone)
# mytz.gettz does not raise exception, returns None if invalid
tz = mytz.gettz(self.timeZone)
if tz:
return tz
return locale_man.localTz
Expand Down Expand Up @@ -2318,7 +2318,7 @@ def getDescription(self):
def getTextParts(self, showDesc=True):
summary = self.getSummary()
# --
if self.timeZoneEnable and self.timeZone and natz.gettz(self.timeZone) is None:
if self.timeZoneEnable and self.timeZone and mytz.gettz(self.timeZone) is None:
invalidTZ = _("Invalid Time Zone: {timeZoneName}").format(
timeZoneName=self.timeZone,
)
Expand Down Expand Up @@ -4102,7 +4102,7 @@ def getSubclass(cls, _type: str) -> "type[EventGroup]":

def getTimeZoneObj(self) -> "datetime.tzinfo":
if self.timeZoneEnable and self.timeZone:
tz = natz.gettz(self.timeZone)
tz = mytz.gettz(self.timeZone)
if tz:
return tz
return locale_man.localTz
Expand Down Expand Up @@ -5609,7 +5609,7 @@ def updateOccurrence(self) -> None:
return
# ----
try:
utc = natz.gettz("UTC")
utc = mytz.gettz("UTC")
self.vcsMinJd = getJdFromEpoch(mod.getFirstCommitEpoch(self), tz=utc)
self.vcsMaxJd = getJdFromEpoch(mod.getLastCommitEpoch(self), tz=utc) + 1
except Exception:
Expand Down
6 changes: 3 additions & 3 deletions scal3/locale_man.py
Expand Up @@ -35,7 +35,7 @@
splitext,
)

import natz
import mytz
from scal3.cal_types import calTypes
from scal3.json_utils import (
jsonToData,
Expand All @@ -53,9 +53,9 @@

# ----------------------------------------------------------

natz.defaultTZ = natz.UTC
mytz.defaultTZ = mytz.UTC

localTz = natz.gettz()
localTz = mytz.gettz()
localTzStr = str(localTz)

# ----------------------------------------------------------
Expand Down
12 changes: 6 additions & 6 deletions scal3/time_utils.py
Expand Up @@ -22,15 +22,15 @@
from datetime import datetime
from time import time as now

import natz
import mytz
from scal3.cal_types.gregorian import J1970, J0001_epoch
from scal3.cal_types.gregorian import jd_to as jd_to_g
from scal3.utils import ifloor

# getEpochFromJd(gregorian.to_jd(10000, 1, 1))
G10000_epoch = 253402300800

TZ: "typing.TypeAlias" = "natz.TimeZone | None"
TZ: "typing.TypeAlias" = "mytz.TimeZone | None"

# jd is the integer value of Chreonological Julian Day,
# which is specific to time zone
Expand Down Expand Up @@ -98,7 +98,7 @@ def getUtcOffsetByEpoch(epoch: int, tz: TZ = None) -> int:
if epoch >= G10000_epoch:
return 0
if not tz:
tz = natz.gettz()
tz = mytz.gettz()
try:
dt = datetime.fromtimestamp(epoch) # noqa: DTZ006
except ValueError as e:
Expand All @@ -113,7 +113,7 @@ def getUtcOffsetByGDate(year: int, month: int, day: int, tz: TZ = None) -> int:
if year >= 10000:
return 0
if not tz:
tz = natz.gettz()
tz = mytz.gettz()
try:
dt = datetime(year, month, day)
except ValueError as e:
Expand All @@ -124,7 +124,7 @@ def getUtcOffsetByGDate(year: int, month: int, day: int, tz: TZ = None) -> int:

def getUtcOffsetByJd(jd: int, tz: TZ = None) -> int:
if not tz:
tz = natz.gettz()
tz = mytz.gettz()
tzStr = str(tz)
# utcOffsetByJdCache: {tzStr => {jd => utcOffset}}
if jd >= J1970:
Expand Down Expand Up @@ -334,7 +334,7 @@ def clockWaitMilliseconds() -> int:


def jsonTimeFromEpoch(epoch: int) -> str:
tm = datetime.fromtimestamp(epoch, tz=natz.UTC)
tm = datetime.fromtimestamp(epoch, tz=mytz.UTC)
# Python's `datetime` does not support "%:z" format ("+03:30")
# so we have to set `tz` to None
return tm.strftime("%Y-%m-%dT%H:%M:%SZ")
Expand Down
6 changes: 3 additions & 3 deletions scal3/ui_gtk/event/bulk_edit.py
Expand Up @@ -2,7 +2,7 @@

log = logger.get()

import natz
import mytz
from scal3.locale_man import tr as _
from scal3.ui_gtk import HBox, VBox, gtk, pack
from scal3.ui_gtk.mywidgets import TextFrame
Expand Down Expand Up @@ -188,8 +188,8 @@ def doAction(self):
chType = self.timeZoneChangeCombo.get_active()
timeZone = self.timeZoneInput.get_text()
if chType != 0:
# natz.gettz does not raise exception, returns None if invalid
if natz.gettz(timeZone):
# mytz.gettz does not raise exception, returns None if invalid
if mytz.gettz(timeZone):
for event in container:
if not (chType == 2 and event.timeZone):
event.timeZone = timeZone
Expand Down
4 changes: 2 additions & 2 deletions scal3/ui_gtk/event/bulk_save_timezone.py
Expand Up @@ -14,7 +14,7 @@
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/agpl.txt>.

import natz
import mytz
from scal3 import ui
from scal3.locale_man import tr as _
from scal3.ui_gtk import HBox, gtk, pack
Expand Down Expand Up @@ -84,7 +84,7 @@ def onResponse(self, _dialog, responseId):
if responseId == gtk.ResponseType.OK:
timeZone = self.timeZoneInput.get_text()
try:
natz.gettz(timeZone)
mytz.gettz(timeZone)
except Exception as e:
self.errorLabel.set_text(
_("Time zone is invalid") + "\n" + str(e),
Expand Down
2 changes: 1 addition & 1 deletion scal3/ui_gtk/mywidgets/tz_combo.py
Expand Up @@ -5,7 +5,7 @@

class TimeZoneComboBoxEntry(gtk.Box):
def __init__(self):
from natz.tree import getZoneInfoTree
from mytz.tree import getZoneInfoTree

gtk.Box.__init__(self, orientation=gtk.Orientation.HORIZONTAL)
model = gtk.TreeStore(str, bool)
Expand Down
2 changes: 1 addition & 1 deletion scripts/load-zoneinfo-tree.py
Expand Up @@ -12,7 +12,7 @@ def dataToPrettyJson(data):


if __name__ == "__main__":
from natz.tree import getZoneInfoTree
from mytz.tree import getZoneInfoTree

zoneTree = getZoneInfoTree(["usr", "share", "zoneinfo"])
# open("data/zoneinfo-tree.json", "w").write(
Expand Down

0 comments on commit 05e874d

Please sign in to comment.