Python datetime.date 模块,isoformat() 实例源码

我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用datetime.date.isoformat()

项目:caltrac    作者:shiburizu    | 项目源码 | 文件源码
def triggerUpdate(self):
        self.caluser.updateProfile(self.inp)
        self.Root.toolbar.title = "CalTrac - %s" % date.isoformat(date.today())
        self.Root.nameLbl.text = 'About ' + self.caluser.getDict('name')
        self.Root.heightLbl.text = 'Height: ' + self.caluser.getDict('height')
        self.Root.weightLbl.text = 'Weight: ' + self.caluser.getDict('weight')
        self.Root.ageLbl.text = 'Age: ' + self.caluser.getDict('age')
        if self.caluser.getDict('preg') == '0':
            self.Root.genderLbl.text = 'Gender: ' + self.caluser.getDict('gender')
            self.Root.kcalTxt.text = 'Kcal target: ' + str(int(float(self.caluser.getDict('bmr'))))
        else:
            self.Root.genderLbl.text = 'Gender: %s (Pregnant)' % self.caluser.getDict('gender') 
            self.Root.kcalTxt.text = 'Kcal target: ' + str(int(float(self.caluser.getDict('bmr')))+350) 
        self.Root.ratingLbl.text = 'Rating: ' + self.caluser.getDict('rating')
        self.nav_drawer.ids['nameBtn'].text = self.caluser.getDict('name')
        self.Profile.ids['profileToolbar'].left_action_items = [['arrow-left', lambda x: self.changeScreens('Root')]]
项目:jsonplus    作者:randomir    | 项目源码 | 文件源码
def test_datetime(self):
        self.assertEqual(self.dump_and_load(self.ts), self.ts.isoformat())
项目:jsonplus    作者:randomir    | 项目源码 | 文件源码
def test_date(self):
        date = self.ts.date()
        self.assertEqual(self.dump_and_load(date), date.isoformat())
项目:jsonplus    作者:randomir    | 项目源码 | 文件源码
def test_time(self):
        time = self.ts.time()
        self.assertEqual(self.dump_and_load(time), time.isoformat())
项目:caltrac    作者:shiburizu    | 项目源码 | 文件源码
def listDelete(self,delta):
        l = c.execute("SELECT rowid, * FROM foods WHERE date = ?", (date.isoformat(date.today() - timedelta(delta)),)).fetchall()
        self.deleteTable.clear_widgets()
        for it in l:
            self.deleteTable.add_widget(DelBtn(text='%s - x%s' % (it[1],str(it[4]).replace('.0','')),
                secondary_text='kcal: %s' % str(it[3]).replace('.0',''),id = str(it[0])))
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def fmt_date(date):
    return "%s, week %d, %s" % (
        date.isoformat(),
        date.isocalendar()[1],
        date.strftime("%A, %B"))
项目:pinax-api    作者:pinax    | 项目源码 | 文件源码
def test_should_coerce_date(self):
        date_ = date.today()
        result = api.resource.resolve_value(date_)
        self.assertEqual(result, date.isoformat(date_))
项目:TripletEmbedding    作者:hrantzsch    | 项目源码 | 文件源码
def __init__(self, args, optimizer, name, extra_msg=''):
        self.iteration = 0
        self.sum_loss = 0
        self.sum_acc = 0
        self.sum_mean_diff = 0
        self.sum_max_diff = 0
        self.current_section = ''
        self.optimizer = optimizer

        # setup according to arguments
        self.name = name if name is not '' else 'signdist'
        self.out_file = "{}_{}".format(date.isoformat(date.today()), self.name)
        self.log_file = "{}.log".format(self.out_file)
        # write config to head of the log file
        self.write_config(args, extra_msg)
项目:TripletEmbedding    作者:hrantzsch    | 项目源码 | 文件源码
def write_config(self, args, extra_msg):
        with open(self.log_file, 'a+') as f:
            self._comment("=" * 40, f)
            self._comment("{} initiated at {}".format(
                self.name, datetime.isoformat(datetime.now())
            ), f)
            self._comment("-" * 40, f)  # arguments passed
            self._comment("Data: " + args.data, f)
            self._comment("Batchsize: {}".format(args.batchsize), f)
            self._comment("Test ratio: {}".format(args.test), f)
            self._comment("Hard triplet ratio: {}".format(args.skilled), f)
            dev = "CPU" if args.gpu < 0 else "GPU ".format(args.gpu)
            self._comment("Device: " + dev, f)
            if args.initmodel:
                self._comment("Init model: " + args.initmodel, f)
            if args.resume:
                self._comment("Resume state: " + args.resume, f)
            self._comment("-" * 40, f)  # parameters set in script
            self._comment("Optimizer: " + self.optimizer.__class__.__name__, f)
            self._comment("Initial LR: {}".format(self.optimizer.lr), f)
            self._comment("LR interval: {}".format(args.lrinterval), f)
            self._comment("Weight decay: {}".format(args.weight_decay), f)
            self._comment("Epoch: {}".format(self.optimizer.epoch), f)
            if extra_msg:
                self._comment(extra_msg, f)
            self._comment("-" * 40, f)  # complete call
            self._comment("{}".format(sys.argv), f)
            self._comment("=" * 40, f)