예제 #1
0
 def timezone(self):
     return Timezone(self.reporting_name())
예제 #2
0
    if cmd.verbose:
        print(cmd, file=sys.stderr)
        sys.stderr.flush()

    # ----------------------------------------------------------------------------------------------------------------
    # resources...

    conf = TimezoneConf.load(Host)

    # ----------------------------------------------------------------------------------------------------------------
    # run...

    now = LocalizedDatetime.now()

    if cmd.list:
        for zone in Timezone.zones():
            print(zone, file=sys.stderr)
        exit(0)

    elif cmd.set():
        if not Timezone.is_valid(cmd.zone):
            print("zone is not valid: %s" % cmd.zone, file=sys.stderr)
            exit(1)

        if cmd.zone != conf.name:
            conf = TimezoneConf(now, cmd.zone)
            conf.save(Host)

    elif cmd.link:
        if not conf.uses_system_name() or conf.set_on is None:
            conf = TimezoneConf(now, None)
예제 #3
0
    def timezone(cls, datum: PathDict):
        jdict = datum.node('status.val.tz')

        return Timezone.construct_from_jdict(jdict)
예제 #4
0
Created on 11 Aug 2017

@author: Bruno Beloff ([email protected])
"""

from tzlocal import get_localzone

from scs_core.data.localized_datetime import LocalizedDatetime
from scs_core.data.json import JSONify

from scs_core.location.timezone import Timezone
from scs_core.location.timezone_conf import TimezoneConf

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

for zone_name in Timezone.zones():
    print(zone_name)

print("=")

zone_name = "Europe/London"  # Etc/UTC  US/Michigan  Europe/London   Asia/Calcutta
print("zone_name: %s" % zone_name)
print("valid: %s" % Timezone.is_valid(zone_name))

print("-")

now = LocalizedDatetime.now()

zone_conf = TimezoneConf(now, zone_name)
print(zone_conf)
print(JSONify.dumps(zone_conf))
예제 #5
0
    cmd = CmdSampleTimezone()

    if not cmd.is_valid():
        cmd.print_help(sys.stderr)
        exit(2)

    if cmd.verbose:
        print("sample_timezone: %s" % cmd, file=sys.stderr)

    try:
        # ------------------------------------------------------------------------------------------------------------
        # resources...

        if cmd.timezone is not None:
            try:
                timezone = Timezone(cmd.timezone)
                zone = timezone.zone

            except ValueError:
                print("sample_timezone: unrecognised name:%s" % cmd.timezone,
                      file=sys.stderr)
                exit(2)

            if cmd.verbose:
                print("sample_timezone: %s" % timezone, file=sys.stderr)
                sys.stderr.flush()

        # ------------------------------------------------------------------------------------------------------------
        # run...

        if cmd.zones: