コード例 #1
0
ファイル: arrow.py プロジェクト: minaeid90/arrow
def arrow(date=None, tz=None):
    def _tz_now(tzinfo):

        date = datetime.utcnow()
        date = date.replace(tzinfo=_tz.tzutc())

        return date.astimezone(tzinfo)

    date_expr = None
    tz_expr = None

    if date is None:
        if tz is None:
            date_expr = datetime.utcnow()
            tz_expr = TimeZone(_tz.tzutc(), date_expr)

        else:
            tz_expr = TimeZone(tz, datetime.utcnow())
            date_expr = _tz_now(tz_expr.tzinfo)

    else:
        if tz is None:
            try:
                tz_expr = TimeZone(date, datetime.utcnow())
                date_expr = _tz_now(tz_expr.tzinfo)
            except:
                date_expr = date
                tz_expr = None

        else:
            date_expr = date
            tz_expr = tz

    return Arrow(date_expr, tz_expr)
コード例 #2
0
ファイル: arrow.py プロジェクト: minaeid90/arrow
    def to(self, tz):

        time_zone = TimeZone(tz, self._datetime)

        _datetime = self._datetime.astimezone(time_zone.tzinfo)

        return Arrow(_datetime, time_zone)
コード例 #3
0
    def __init__(self,
                 account_number,
                 first_name,
                 last_name,
                 time_zone=None,
                 initial_balance=0):
        self._account_number = account_number
        self.first_name = first_name
        self.last_name = last_name

        if time_zone is None:
            time_zone = TimeZone("UTC", 0, 0)
        self.time_zone = time_zone

        self._balance = float(initial_balance)
コード例 #4
0
ファイル: arrow.py プロジェクト: minaeid90/arrow
    def _parse(dt_expr, tz_expr):

        _datetime = Arrow._try_parse_timestamp(dt_expr, tz_expr)

        if _datetime is None:

            if isinstance(dt_expr, datetime):
                _datetime = dt_expr

        if _datetime is None:
            raise ValueError('Could not recognize datetime')

        timezone = TimeZone(tz_expr, _datetime)
        _datetime = _datetime.replace(tzinfo=timezone.tzinfo)

        return _datetime, timezone
コード例 #5
0
ファイル: arrow.py プロジェクト: minaeid90/arrow
    def _try_parse_timestamp(dt_expr, timezone):

        _datetime = None

        try:
            dt_expr = float(dt_expr)

            _datetime = datetime.utcfromtimestamp(dt_expr)
            timezone = TimeZone(timezone, _datetime)

            if not timezone.utc:
                _datetime = _datetime.replace(tzinfo=_tz.tzutc()).astimezone(
                    timezone.tzinfo)

        except:
            pass

        return _datetime
コード例 #6
0
    def parse_confirmation_code(confirmation_code, preferred_time_zone=None):
        parts = confirmation_code.split("-")

        if len(parts) != 4:
            raise ValueError("Invalid Confirmation Code.")

        transaction_code, account_number, raw_dt_utc, transaction_id = parts

        try:
            dt_utc = datetime.strptime(raw_dt_utc, "%Y%m%d%H%M%S")
        except ValueError as ex:
            raise ValueError("Invalid Transction Datetime.") from ex

        if preferred_time_zone is None:
            preferred_time_zone = TimeZone("UTC", 0, 0)

        if not isinstance(preferred_time_zone, TimeZone):
            raise ValueError("Invalid Timezone specified.")

        dt_preferred = dt_utc + preferred_time_zone.offset
        dt_preferred_str = f"{dt_preferred.strftime('%Y-%m-%d %H:%M:%S')} ({preferred_time_zone.name})"

        return Confirmation(account_number, transaction_code, transaction_id,
                            dt_utc.isoformat(), dt_preferred_str)
コード例 #7
0
ファイル: gbiWindow.py プロジェクト: szxsun/gbi
 def next_page(self, widget, notebook):
     """Go to the next window."""
     page = self.notebook.get_current_page()
     if page == 0:
         self.lang.save_selection()
         kbbox = Gtk.VBox(False, 0)
         kbbox.show()
         self.kb = Keyboard(self.button3)
         get_kb = self.kb.get_model()
         kbbox.pack_start(get_kb, True, True, 0)
         label = Gtk.Label("Keyboard")
         self.notebook.insert_page(kbbox, label, 1)
         self.window.show_all()
         self.notebook.next_page()
         self.button1.set_sensitive(True)
         self.button3.set_sensitive(False)
     elif page == 1:
         self.kb.save_selection()
         tbbox = Gtk.VBox(False, 0)
         tbbox.show()
         self.tz = TimeZone(self.button3)
         get_tz = self.tz.get_model()
         tbbox.pack_start(get_tz, True, True, 0)
         label = Gtk.Label("TimeZone")
         self.notebook.insert_page(tbbox, label, 2)
         self.window.show_all()
         self.notebook.next_page()
         self.button3.set_sensitive(False)
     elif page == 2:
         self.tz.save_selection()
         typebox = Gtk.VBox(False, 0)
         typebox.show()
         self.types = Types()
         get_types = self.types.get_model()
         typebox.pack_start(get_types, True, True, 0)
         label = Gtk.Label("Types")
         self.notebook.insert_page(typebox, label, 3)
         self.window.show_all()
         self.notebook.next_page()
     elif page == 3:
         if self.types.get_type() == "ufs":
             partition_repos()
             udbox = Gtk.VBox(False, 0)
             udbox.show()
             self.partition = use_ufs(self.button3)
             get_ud = self.partition.get_model()
             udbox.pack_start(get_ud, True, True, 0)
             label = Gtk.Label("UFS Disk Configuration")
             self.notebook.insert_page(udbox, label, 4)
             self.window.show_all()
             self.notebook.next_page()
             self.button3.set_sensitive(False)
         elif self.types.get_type() == "custom":
             partition_repos()
             Pbox = Gtk.VBox(False, 0)
             Pbox.show()
             self.partition = Partitions(self.button3)
             get_part = self.partition.get_model()
             Pbox.pack_start(get_part, True, True, 0)
             label = Gtk.Label("UFS Custom Configuration")
             self.notebook.insert_page(Pbox, label, 4)
             self.window.show_all()
             self.notebook.next_page()
             self.button3.set_sensitive(False)
         elif self.types.get_type() == "zfs":
             Zbox = Gtk.VBox(False, 0)
             Zbox.show()
             self.partition = ZFS(self.button3)
             get_ZFS = self.partition.get_model()
             Zbox.pack_start(get_ZFS, True, True, 0)
             label = Gtk.Label("ZFS Configuration")
             self.notebook.insert_page(Zbox, label, 4)
             self.window.show_all()
             self.notebook.next_page()
             self.button3.set_sensitive(False)
     elif page == 4:
         self.partition.save_selection()
         Rbox = Gtk.VBox(False, 0)
         Rbox.show()
         self.rootuser = RootUser(self.button3)
         get_root = self.rootuser.get_model()
         Rbox.pack_start(get_root, True, True, 0)
         label = Gtk.Label("Root Password")
         self.notebook.insert_page(Rbox, label, 5)
         self.window.show_all()
         self.notebook.next_page()
         self.button3.set_sensitive(False)
     elif page == 5:
         self.rootuser.save_selection()
         Abox = Gtk.VBox(False, 0)
         Abox.show()
         self.adduser = AddUser(self.button3)
         get_adduser = self.adduser.get_model()
         Abox.pack_start(get_adduser, True, True, 0)
         label = Gtk.Label("Adding User")
         self.notebook.insert_page(Abox, label, 6)
         self.button3.set_label("Install")
         self.window.show_all()
         self.notebook.next_page()
         self.button3.set_sensitive(False)
     elif page == 6:
         self.adduser.save_selection()
         Ibox = Gtk.VBox(False, 0)
         Ibox.show()
         install = installSlide()
         get_install = install.get_model()
         Ibox.pack_start(get_install, True, True, 0)
         label = Gtk.Label("Installation")
         self.notebook.insert_page(Ibox, label, 7)
         self.notebook.next_page()
         instpro = installProgress()
         progressBar = instpro.getProgressBar()
         box1 = Gtk.VBox(False, 0)
         box1.show()
         label = Gtk.Label("Progress Bar")
         box1.pack_end(progressBar, False, False, 0)
         self.nbButton.insert_page(box1, label, 1)
         self.nbButton.next_page()
         self.window.show_all()
コード例 #8
0
    def __init__(self, date, tz='UTC'):

        self._timezone = TimeZone(tz)
        self._datetime = self._get_datetime(date, self._timezone)
コード例 #9
0
    def pay_interest(self):
        interest = self.balance * Account.get_interest_rate() / 100
        transaction_code = Account._transaction_codes["interest"]
        conf_code = self.generate_confirmation_code(transaction_code)
        self._balance += interest
        return conf_code


if __name__ == "__main__":
    #a1 = Account(1234, None, None)
    #a1.first_name
    a2 = Account(1234, "Tyrion", "Lannister", initial_balance=100)
    print(a2.first_name)
    print(a2.last_name)

    a2.timezone = TimeZone('MST', -7, 0)

    print(a2.timezone)

    #a3 = Account(5467, "Jamie", "Lannister", "-7:00")

    a4 = Account(5467, "Cersei", "Lannister", initial_balance=100)
    print(a4.balance)

    #a2.balance = 50

    print(Account.get_interest_rate())
    Account.set_interest_rate(10)
    print(Account.get_interest_rate())

    confirmation_code = a2.make_transactions()