• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.formatdate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中webnotes.utils.formatdate函数的典型用法代码示例。如果您正苦于以下问题:Python formatdate函数的具体用法?Python formatdate怎么用?Python formatdate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了formatdate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: check_if_expired

def check_if_expired():
	"""check if account is expired. If expired, do not allow login"""
	import conf
	# check if expires_on is specified
	if not hasattr(conf, 'expires_on'): return
	
	# check if expired
	from datetime import datetime, date
	expires_on = datetime.strptime(conf.expires_on, '%Y-%m-%d').date()
	if date.today() <= expires_on: return
	
	# if expired, stop user from logging in
	from webnotes.utils import formatdate
	if 'System Manager' in webnotes.user.roles:
		webnotes.response['server_messages'] = """Oops! \
			Your subscription expired on <b>%s</b>.
			
			Nothing catastrophic.
			
			Just drop in a mail at <b>[email protected]</b> and \
			we will guide you to get your account re-activated.""" % formatdate(conf.expires_on)
	else:
		webnotes.response['server_messages'] = """Oops! \
			Your subscription expired on <b>%s</b>.
			
			Nothing catastrophic.
					
			Just ask your System Manager to drop in a mail at <b>[email protected]</b> and \
			we will guide him to get your account re-activated.""" % formatdate(conf.expires_on)
	
	webnotes.response['message'] = 'Account Expired'
	raise webnotes.AuthenticationError
开发者ID:NorrWing,项目名称:erpnext,代码行数:32,代码来源:event_handlers.py


示例2: get_msg_html

	def get_msg_html(self, out):
		with_value = [o[1] for o in out if o[0]]
		
		if with_value:
			with_value = "\n".join(with_value)
		else:
			with_value = "<p>There were no updates in the items selected for this digest.</p>"
		
		# seperate out no value items
		no_value = [o[1] for o in out if not o[0]]
		if no_value:
			no_value = """<h4>No Updates For:</h4>""" + "\n".join(no_value)
		
		date = self.doc.frequency == "Daily" and formatdate(self.from_date) or \
			"%s to %s" % (formatdate(self.from_date), formatdate(self.to_date))
		
		msg = digest_template % {
				"digest": self.doc.frequency + " Digest",
				"date": date,
				"company": self.doc.company,
				"with_value": with_value,
				"no_value": no_value or ""
			}
		
		return msg
开发者ID:aalishanmatrix,项目名称:erpnext,代码行数:25,代码来源:email_digest.py


示例3: get_msg_html

	def get_msg_html(self, out):
		with_value = "\n".join([o[1] for o in out if o[0]])
		
		# seperate out no value items
		no_value = [o[1] for o in out if not o[0]]
		if no_value:
			no_value = """<hr><h4>No Updates For:</h4><br>""" + "\n".join(no_value)
		
		date = self.doc.frequency == "Daily" and formatdate(self.from_date) or \
			"%s to %s" % (formatdate(self.from_date), formatdate(self.to_date))
		
		msg = """<h2>%(digest)s</h2>
			<p style='color: grey'>%(date)s</p>
			<h4>%(company)s</h4>
			<hr>
			%(with_value)s
			%(no_value)s""" % {
				"digest": self.doc.frequency + " Digest",
				"date": date,
				"company": self.doc.company,
				"with_value": with_value,
				"no_value": no_value or ""
			}
		
		return msg
开发者ID:trycatcher,项目名称:erpnext,代码行数:25,代码来源:email_digest.py


示例4: validate_leave_overlap

    def validate_leave_overlap(self):
        if not self.doc.name:
            self.doc.name = "New Leave Application"

        for d in webnotes.conn.sql(
            """select name, leave_type, posting_date, 
			from_date, to_date 
			from `tabLeave Application` 
			where 
			employee = %(employee)s
			and docstatus < 2
			and status in ("Open", "Approved")
			and (from_date between %(from_date)s and %(to_date)s 
				or to_date between %(from_date)s and %(to_date)s
				or %(from_date)s between from_date and to_date)
			and name != %(name)s""",
            self.doc.fields,
            as_dict=1,
        ):

            msgprint(
                'Employee : %s has already applied for %s between %s and %s on %s. Please refer Leave Application : <a href="#Form/Leave Application/%s">%s</a>'
                % (
                    self.doc.employee,
                    cstr(d["leave_type"]),
                    formatdate(d["from_date"]),
                    formatdate(d["to_date"]),
                    formatdate(d["posting_date"]),
                    d["name"],
                    d["name"],
                ),
                raise_exception=OverlapError,
            )
开发者ID:nabinhait,项目名称:erpnext,代码行数:33,代码来源:leave_application.py


示例5: create_remarks

	def create_remarks(self):
		r = []
		if self.doc.cheque_no :
			if self.doc.cheque_date:
				r.append('Via Reference #%s dated %s' % 
					(self.doc.cheque_no, formatdate(self.doc.cheque_date)))
			else :
				msgprint("Please enter Reference date", raise_exception=1)
		
		for d in getlist(self.doclist, 'entries'):
			if d.against_invoice and d.credit:
				currency = webnotes.conn.get_value("Sales Invoice", d.against_invoice, "currency")
				r.append('%s %s against Invoice: %s' % 
					(cstr(currency), fmt_money(flt(d.credit)), d.against_invoice))
					
			if d.against_voucher and d.debit:
				bill_no = webnotes.conn.sql("""select bill_no, bill_date, currency 
					from `tabPurchase Invoice` where name=%s""", d.against_voucher)
				if bill_no and bill_no[0][0] and bill_no[0][0].lower().strip() \
						not in ['na', 'not applicable', 'none']:
					r.append('%s %s against Bill %s dated %s' % 
						(cstr(bill_no[0][2]), fmt_money(flt(d.debit)), bill_no[0][0], 
						bill_no[0][1] and formatdate(bill_no[0][1].strftime('%Y-%m-%d')) or ''))
	
		if self.doc.user_remark:
			r.append("User Remark : %s"%self.doc.user_remark)

		if r:
			self.doc.remark = ("\n").join(r)
		else:
			webnotes.msgprint("User Remarks is mandatory", raise_exception=1)
开发者ID:cocoy,项目名称:erpnext,代码行数:31,代码来源:journal_voucher.py


示例6: upload_accounts_transactions

    def upload_accounts_transactions(self):
        import csv

        data = csv.reader(self.get_csv_data().splitlines())

        abbr = sql("select concat(' - ',abbr) as abbr from tabCompany where name=%s", self.doc.company)
        updated = 0
        jv_name = ""
        # 		jv = Document('Journal Voucher')
        global line, jv, name, jv_go
        for line in data:
            if len(line) >= 7:  # Minimum no of fields
                if line[3] != jv_name:  # Create JV
                    if jv_name != "":
                        jv_go = get_obj("Journal Voucher", name, with_children=1)
                        jv_go.validate()
                        jv_go.on_submit()

                    jv_name = line[3]
                    jv = Document("Journal Voucher")
                    jv.voucher_type = line[0]
                    jv.naming_series = line[1]
                    jv.voucher_date = formatdate(line[2])
                    jv.posting_date = formatdate(line[2])
                    # 					jv.name = line[3]
                    jv.fiscal_year = self.doc.fiscal_year
                    jv.company = self.doc.company
                    jv.remark = len(line) == 8 and line[3] + " " + line[7] or line[3] + " Uploaded Record"
                    jv.docstatus = 1
                    jv.save(1)
                    name = jv.name

                    jc = addchild(jv, "entries", "Journal Voucher Detail", 0)
                    jc.account = line[4] + abbr[0][0]
                    jc.cost_center = len(line) == 9 and line[8] or self.doc.default_cost_center
                    if line[5] != "":
                        jc.debit = line[5]
                    else:
                        jc.credit = line[6]
                    jc.save()

                else:  # Create JV Child
                    jc = addchild(jv, "entries", "Journal Voucher Detail", 0)
                    jc.account = line[4] + abbr[0][0]
                    jc.cost_center = len(line) == 9 and line[8] or self.doc.default_cost_center
                    if line[5] != "":
                        jc.debit = line[5]
                    else:
                        jc.credit = line[6]
                    jc.save()
            else:
                msgprint("[Ignored] Incorrect format: %s" % str(line))
        if jv_name != "":
            jv_go = get_obj("Journal Voucher", name, with_children=1)
            jv_go.validate()
            jv_go.on_submit()

        msgprint("<b>%s</b> items updated" % updated)
开发者ID:Vichagserp,项目名称:cimworks,代码行数:58,代码来源:upload_accounts_transactions.py


示例7: validate_bill_no

 def validate_bill_no(self):
     if self.doc.bill_no and self.doc.bill_no.lower().strip() not in ["na", "not applicable", "none"]:
         b_no = sql(
             "select bill_no, name, ifnull(is_opening,'') from `tabPurchase Invoice` where bill_no = '%s' and credit_to = '%s' and docstatus = 1 and name != '%s' "
             % (self.doc.bill_no, self.doc.credit_to, self.doc.name)
         )
         if b_no and cstr(b_no[0][2]) == cstr(self.doc.is_opening):
             msgprint(
                 "Please check you have already booked expense against Bill No. %s in Purchase Invoice %s"
                 % (cstr(b_no[0][0]), cstr(b_no[0][1]))
             )
             raise Exception, "Validation Error"
         if not self.doc.remarks:
             self.doc.remarks = (
                 (self.doc.remarks or "")
                 + "\n"
                 + ("Against Bill %s dated %s" % (self.doc.bill_no, formatdate(self.doc.bill_date)))
             )
             if self.doc.ded_amount:
                 self.doc.remarks = (
                     (self.doc.remarks or "")
                     + "\n"
                     + ("Grand Total: %s, Tax Deduction Amount: %s" % (self.doc.grand_total, self.doc.ded_amount))
                 )
     else:
         if not self.doc.remarks:
             self.doc.remarks = "No Remarks"
开发者ID:smilekk,项目名称:erpnext,代码行数:27,代码来源:purchase_invoice.py


示例8: validate_block_days

    def validate_block_days(self):
        from_date = getdate(self.doc.from_date)
        to_date = getdate(self.doc.to_date)

        department = webnotes.conn.get_value("Employee", self.doc.employee, "department")
        if department:
            block_list = webnotes.conn.get_value("Department", department, "holiday_block_list")
            if block_list:
                if self.is_user_in_allow_list(block_list):
                    return
                for d in webnotes.conn.sql(
                    """select block_date, reason from
					`tabHoliday Block List Date` where parent=%s""",
                    block_list,
                    as_dict=1,
                ):
                    block_date = getdate(d.block_date)
                    if block_date > from_date and block_date < to_date:
                        webnotes.msgprint(
                            _("You cannot apply for a leave on the following date because it is blocked")
                            + ": "
                            + formatdate(d.block_date)
                            + _(" Reason: ")
                            + d.reason
                        )
                        raise LeaveDayBlockedError
开发者ID:robertbecht,项目名称:erpnext,代码行数:26,代码来源:leave_application.py


示例9: create_remarks

	def create_remarks(self):
		r = []
		if self.doc.cheque_no :
			if self.doc.cheque_date:
				r.append('Via Reference #%s dated %s' % (self.doc.cheque_no, formatdate(self.doc.cheque_date)))
			else :
				msgprint("Please enter Reference date")
				raise Exception
		
		for d in getlist(self.doclist, 'entries'):
			if d.against_invoice and d.credit:
				currency = sql("select currency from `tabSales Invoice` where name = '%s'" % d.against_invoice)
				currency = currency and currency[0][0] or ''
				r.append('%s %s against Invoice: %s' % (cstr(currency), fmt_money(flt(d.credit)), d.against_invoice))
			if d.against_voucher and d.debit:
				bill_no = sql("select bill_no, bill_date, currency from `tabPurchase Invoice` where name=%s", d.against_voucher)
				if bill_no and bill_no[0][0] and bill_no[0][0].lower().strip() not in ['na', 'not applicable', 'none']:
					bill_no = bill_no and bill_no[0]
					r.append('%s %s against Bill %s dated %s' % (bill_no[2] and cstr(bill_no[2]) or '', fmt_money(flt(d.debit)), bill_no[0], bill_no[1] and formatdate(bill_no[1].strftime('%Y-%m-%d')) or ''))
	
		if self.doc.user_remark:
			r.append("User Remark : %s"%self.doc.user_remark)

		if r:
			self.doc.remark = ("\n").join(r)
开发者ID:arunemmanuel,项目名称:erpnext,代码行数:25,代码来源:journal_voucher.py


示例10: convert_to_simple_type

	def convert_to_simple_type(self, v, formatted=0):
		from webnotes.utils import formatdate, fmt_money

		if isinstance(v, (datetime.date, datetime.timedelta, datetime.datetime, long)):
			if isinstance(v, datetime.date):
				v = unicode(v)
				if formatted:
					v = formatdate(v)
		
			# time
			elif isinstance(v, (datetime.timedelta, datetime.datetime)):
				v = unicode(v)
				
			# long
			elif isinstance(v, long): 
				v=int(v)

		# convert to strings... (if formatted)
		if formatted:
			if isinstance(v, float):
				v=fmt_money(v)
			elif isinstance(v, int):
				v = unicode(v)

		return v
开发者ID:saurabh6790,项目名称:pow-lib,代码行数:25,代码来源:db.py


示例11: datetime_in_user_format

def datetime_in_user_format(date_time):
	if not date_time:
		return ""
	if isinstance(date_time, basestring):
		date_time = get_datetime(date_time)
	from webnotes.utils import formatdate
	return formatdate(date_time.date()) + " " + date_time.strftime("%H:%M")
开发者ID:Halfnhav,项目名称:wnframework,代码行数:7,代码来源:dateutils.py


示例12: check_if_expired

def check_if_expired():
    """check if account is expired. If expired, do not allow login"""
    from webnotes import conf

    # check if expires_on is specified
    if not "expires_on" in conf:
        return

    # check if expired
    from datetime import datetime, date

    expires_on = datetime.strptime(conf.expires_on, "%Y-%m-%d").date()
    if date.today() <= expires_on:
        return

    # if expired, stop user from logging in
    from webnotes.utils import formatdate

    msg = """Oops! Your subscription expired on <b>%s</b>.<br>""" % formatdate(conf.expires_on)

    if "System Manager" in webnotes.user.get_roles():
        msg += """Just drop in a mail at <b>[email protected]</b> and
			we will guide you to get your account re-activated."""
    else:
        msg += """Just ask your System Manager to drop in a mail at <b>[email protected]</b> and
		we will guide him to get your account re-activated."""

    webnotes.msgprint(msg)

    webnotes.response["message"] = "Account Expired"
    raise webnotes.AuthenticationError
开发者ID:neerajthakur11,项目名称:erpnext,代码行数:31,代码来源:event_handlers.py


示例13: convert_to_simple_type

	def convert_to_simple_type(self, v, formatted=0):
		import datetime
		from webnotes.utils import formatdate, fmt_money

		# date
		if type(v)==datetime.date:
			v = str(v)
			if formatted:
				v = formatdate(v)
		
		# time	
		elif type(v)==datetime.timedelta:
			h = int(v.seconds/60/60)
			v = str(h) + ':' + str(v.seconds/60 - h*60)
			if v[1]==':': 
				v='0'+v
		
		# datetime
		elif type(v)==datetime.datetime:
			v = str(v)
		
		# long
		elif type(v)==long: 
			v=int(v)
		
		# convert to strings... (if formatted)
		if formatted:
			if type(v)==float:
				v=fmt_money(v)
			if type(v)==int:
				v=str(v)
		
		return v
开发者ID:gowrav-vishwakarma,项目名称:wnframework,代码行数:33,代码来源:db.py


示例14: get_transaction_list

def get_transaction_list(doctype, start):
    # find customer id
    customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, "customer")

    if customer:
        transactions = webnotes.conn.sql(
            """select name, creation, currency, grand_total_export 
			from `tab%s` where customer=%s and docstatus=1
			order by creation desc
			limit %s, 20"""
            % (doctype, "%s", "%s"),
            (customer, cint(start)),
            as_dict=True,
        )
        for doc in transactions:
            doc.items = ", ".join(
                webnotes.conn.sql_list(
                    """select item_name
				from `tab%s Item` where parent=%s limit 5"""
                    % (doctype, "%s"),
                    doc.name,
                )
            )
            doc.creation = formatdate(doc.creation)
        return transactions
    else:
        return []
开发者ID:rohitw1991,项目名称:latestadberp,代码行数:27,代码来源:transaction.py


示例15: convert_to_simple_type

	def convert_to_simple_type(self, v, formatted=0):
		import datetime
		from webnotes.utils import formatdate, fmt_money

		# date
		if type(v)==datetime.date:
			v = unicode(v)
			if formatted:
				v = formatdate(v)
		
		# time	
		elif type(v)==datetime.timedelta:
			v = unicode(v)
		
		# datetime
		elif type(v)==datetime.datetime:
			v = unicode(v)
		
		# long
		elif type(v)==long: 
			v=int(v)
		
		# convert to strings... (if formatted)
		if formatted:
			if type(v)==float:
				v=fmt_money(v)
			if type(v)==int:
				v=str(v)
		
		return v
开发者ID:MiteshC,项目名称:wnframework,代码行数:30,代码来源:db.py


示例16: get_transaction_list

def get_transaction_list(doctype, start, additional_fields=None):
	# find customer id
	customer = webnotes.conn.get_value("Contact", {"email_id": webnotes.session.user}, 
		"customer")
	
	if customer:
		if additional_fields:
			additional_fields = ", " + ", ".join(("`%s`" % f for f in additional_fields))
		else:
			additional_fields = ""
			
		transactions = webnotes.conn.sql("""select name, creation, currency, grand_total_export
			%s
			from `tab%s` where customer=%s and docstatus=1
			order by creation desc
			limit %s, 20""" % (additional_fields, doctype, "%s", "%s"), 
			(customer, cint(start)), as_dict=True)
		for doc in transactions:
			items = webnotes.conn.sql_list("""select item_name
				from `tab%s Item` where parent=%s limit 6""" % (doctype, "%s"), doc.name)
			doc.items = ", ".join(items[:5]) + ("..." if (len(items) > 5) else "")
			doc.creation = formatdate(doc.creation)
		return transactions
	else:
		return []
开发者ID:Anirudh887,项目名称:erpnext,代码行数:25,代码来源:utils.py


示例17: validate_fiscal_year

def validate_fiscal_year(date, fiscal_year, label="Date"):
    years = [f[0] for f in get_fiscal_years(date, label=label)]
    if fiscal_year not in years:
        webnotes.msgprint(
            ("%(label)s '%(posting_date)s': " + _("not within Fiscal Year") + ": '%(fiscal_year)s'")
            % {"label": label, "posting_date": formatdate(date), "fiscal_year": fiscal_year},
            raise_exception=1,
        )
开发者ID:nivawebs,项目名称:erpnext,代码行数:8,代码来源:utils.py


示例18: get_emails

def get_emails(start=0):
	emails = webnotes.conn.sql("""select name, subject, status, creation 
		from `tabEmail Inbox` where raised_by=%s 
		order by modified desc
		limit %s, 20""", (webnotes.session.user, cint(start)), as_dict=True)
	for t in emails:
		t.creation = formatdate(t.creation)
	
	return emails
开发者ID:gangadhar-kadam,项目名称:prj,代码行数:9,代码来源:emails.py


示例19: validate_fiscal_year

	def validate_fiscal_year(self, fiscal_year, transaction_date, label):
		from accounts.utils import get_fiscal_year
		if get_fiscal_year(transaction_date)[0] != fiscal_year:
			msgprint(("%(label)s '%(posting_date)s': " + _("not within Fiscal Year") + \
				": '%(fiscal_year)s'") % {
					"label": label,
					"posting_date": formatdate(transaction_date),
					"fiscal_year": fiscal_year
				}, raise_exception=1)
开发者ID:AminfiBerlin,项目名称:erpnext,代码行数:9,代码来源:sales_common.py


示例20: get_tickets

def get_tickets(start=0):
	tickets = webnotes.conn.sql("""select name, subject, status, creation 
		from `tabSupport Ticket` where raised_by=%s 
		order by modified desc
		limit %s, 20""", (webnotes.session.user, cint(start)), as_dict=True)
	for t in tickets:
		t.creation = formatdate(t.creation)
	
	return tickets
开发者ID:akaifi,项目名称:shopping-cart,代码行数:9,代码来源:tickets.py



注:本文中的webnotes.utils.formatdate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.get_base_path函数代码示例发布时间:2022-05-26
下一篇:
Python utils.fmt_money函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap