本文整理汇总了Python中trac.util.datefmt.format_datetime函数的典型用法代码示例。如果您正苦于以下问题:Python format_datetime函数的具体用法?Python format_datetime怎么用?Python format_datetime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了format_datetime函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_format_datetime_utc
def test_format_datetime_utc(self):
t = datetime.datetime(1970, 1, 1, 1, 0, 23, 0, datefmt.utc)
expected = "1970-01-01T01:00:23Z"
self.assertEqual(datefmt.format_datetime(t, "%Y-%m-%dT%H:%M:%SZ", datefmt.utc), expected)
self.assertEqual(datefmt.format_datetime(t, "iso8601", datefmt.utc), expected)
self.assertEqual(datefmt.format_datetime(t, "iso8601date", datefmt.utc), expected.split("T")[0])
self.assertEqual(datefmt.format_datetime(t, "iso8601time", datefmt.utc), expected.split("T")[1])
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:7,代码来源:datefmt.py
示例2: _all_my_projects
def _all_my_projects(self,owner):
all_my_projects=[]
cnx=self.env.get_db_cnx()
cur=cnx.cursor()
cur.execute("select * from project where owner='%s'order by id desc;"%owner)
cur.close()
cnx.commit()
cnx.close()
for i in cur:
tmp={}
tmp['proj_full_name']=i[4]
tmp['proj_name']=i[3]
if len(i[5])>20:
tmp['short_description']=i[5][:19]+'...'
else:
tmp['short_description']=i[5]
tmp['description']=i[5]
tmp['apply_time']=format_datetime(i[6]) #format_datatime(None) is equal to format_date
if i[7] is None:
tmp['exam_time']=''
else:
tmp['exam_time']=format_datetime(i[7])
if i[8]==0:
tmp['stat']='pending'
elif i[8]==1:
tmp['stat']='approved'
else:
tmp['stat']='rejected'
all_my_projects.append(tmp)
return all_my_projects
开发者ID:zjj,项目名称:ProjectsManager,代码行数:31,代码来源:projectsmanager.py
示例3: event_as_dict
def event_as_dict(event, own=False):
tt = event.time_track
time = 0
if tt and tt.exists:
time = tt.time
else:
if event.allday:
time = 24 * 60 # all day event is 24 hours long
else:
time = (event.dtend - event.dtstart).seconds / 60
e = {
"id": event.id,
"start": format_datetime(event.dtstart, "iso8601", utc),
"end": format_datetime(event.dtend, "iso8601", utc),
"allDay": event.allday == 1,
"name": event.title,
"own": own,
"calendar": event.calendar,
"description": event.description,
"ticket": event.ticket,
"timetrack": tt and True or False,
"auto": (tt and tt.auto and True) or (tt is None and True) or False,
"time": "%02d:%02d" % (time / 60, time % 60),
}
return e
开发者ID:rcarmo,项目名称:IttecoTracPlugin,代码行数:26,代码来源:util.py
示例4: expand_macro
def expand_macro(self, formatter, name, content):
env = formatter.env
req = formatter.req
if not 'VOTE_VIEW' in req.perm:
return
# Simplify function calls.
format_author = partial(Chrome(self.env).format_author, req)
if not content:
args = []
compact = None
kw = {}
top = 5
else:
args, kw = parse_args(content)
compact = 'compact' in args and True
top = as_int(kw.get('top'), 5, min=0)
if name == 'LastVoted':
lst = tag.ul()
for i in self.get_votes(req, top=top):
resource = Resource(i[0], i[1])
# Anotate who and when.
voted = ('by %s at %s'
% (format_author(i[3]),
format_datetime(to_datetime(i[4]))))
lst(tag.li(tag.a(
get_resource_description(env, resource, compact and
'compact' or 'default'),
href=get_resource_url(env, resource, formatter.href),
title=(compact and '%+i %s' % (i[2], voted) or None)),
(not compact and Markup(' %s %s' % (tag.b('%+i' % i[2]),
voted)) or '')))
return lst
elif name == 'TopVoted':
realm = kw.get('realm')
lst = tag.ul()
for i in self.get_top_voted(req, realm=realm, top=top):
if 'up-only' in args and i[2] < 1:
break
resource = Resource(i[0], i[1])
lst(tag.li(tag.a(
get_resource_description(env, resource, compact and
'compact' or 'default'),
href=get_resource_url(env, resource, formatter.href),
title=(compact and '%+i' % i[2] or None)),
(not compact and ' (%+i)' % i[2] or '')))
return lst
elif name == 'VoteList':
lst = tag.ul()
resource = resource_from_path(env, req.path_info)
for i in self.get_votes(req, resource, top=top):
vote = ('at %s' % format_datetime(to_datetime(i[4])))
lst(tag.li(
compact and format_author(i[3]) or
Markup(u'%s by %s %s' % (tag.b('%+i' % i[2]),
tag(format_author(i[3])), vote)),
title=(compact and '%+i %s' % (i[2], vote) or None)))
return lst
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:60,代码来源:__init__.py
示例5: test_format_datetime_gmt01
def test_format_datetime_gmt01(self):
gmt01 = datefmt.FixedOffset(60, "GMT +1:00")
t = datetime.datetime(1970, 1, 1, 1, 0, 23, 0, gmt01)
self.assertEqual("1970-01-01T01:00:23+0100", datefmt.format_datetime(t, "%Y-%m-%dT%H:%M:%S%z", gmt01))
expected = "1970-01-01T01:00:23+01:00"
self.assertEqual(datefmt.format_datetime(t, "iso8601", gmt01), expected)
self.assertEqual(datefmt.format_datetime(t, "iso8601date", gmt01), expected.split("T")[0])
self.assertEqual(datefmt.format_datetime(t, "iso8601time", gmt01), expected.split("T")[1])
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:8,代码来源:datefmt.py
示例6: render_admin_panel
def render_admin_panel(self, req, cat, page, path_info):
req.perm.require('SVNVERIFY_REPORT')
rm = RepositoryManager(self.env)
all_repos = rm.get_all_repositories()
db = self.env.get_read_db()
cursor = db.cursor()
if path_info:
# detailed
reponame = not is_default(path_info) and path_info or ''
info = all_repos.get(reponame)
if info is None:
raise TracError(_("Repository '%(repo)s' not found",
repo=path_info))
cursor.execute("SELECT type, time, result, log "
"FROM svnverify_log WHERE repository_id = %s "
"ORDER BY time DESC LIMIT 1",
(info['id'],))
row = cursor.fetchone()
if row:
info['check_type'] = row[0]
info['time_checked'] = format_datetime(from_utimestamp(row[1]))
info['pretty_status'] = int(row[2]) == 0 and "OK" or "Warning"
info['status'] = row[2]
info['log'] = row[3]
info['prettydir'] = breakable_path(info['dir'])
if info['name'] == '':
info['name'] = "(default)"
return 'svnverify.html', {"info": info}
else:
repositories = {}
for reponame, info in all_repos.iteritems():
if info.get('type',rm.repository_type) == "svn" or (rm.repository_type == 'svn' and info.get('type') == ''):
info['prettydir'] = breakable_path(info['dir'])
try:
r = RepositoryManager(self.env).get_repository(reponame)
info['rev'] = r.get_youngest_rev()
info['display_rev'] = r.display_rev(info['rev'])
except:
pass
cursor.execute("SELECT type, time, result "
"FROM svnverify_log "
"WHERE repository_id = %s "
"ORDER BY time DESC LIMIT 1",
(info['id'],))
row = cursor.fetchone()
if row:
info['check_type'] = row[0]
info['time_checked'] = format_datetime(from_utimestamp(row[1]))
info['pretty_status'] = int(row[2]) == 0 and "OK" or "Warning"
info['status'] = row[2]
repositories[reponame] = info
add_stylesheet(req, 'svnverify/css/svnverify.css')
return 'svnverifylist.html', {"repositories": repositories}
开发者ID:CGI-define-and-primeportal,项目名称:trac-plugin-svnverify,代码行数:58,代码来源:web_ui.py
示例7: runTest
def runTest(self):
self._tester.login_as(Usernames.admin)
# Create the milestone first
self._tester.create_milestone('milestone2')
# get sprint listing, should be empty
page_url = self._tester.url + '/admin/agilo/sprints'
tc.go(page_url)
tc.url(page_url)
tc.code(200)
# add new sprint
sprint_start = normalize_date(now())
sprint_name = 'Test sprint'
tc.formvalue('addsprint', 'name', sprint_name)
tc.formvalue('addsprint', 'start', format_datetime(sprint_start, format='iso8601'))
tc.formvalue('addsprint', 'duration', '1')
tc.formvalue('addsprint', 'milestone', 'milestone2')
tc.submit('add')
# add redirects to list view, new sprint should be in there
tc.find(sprint_name)
# go to detail page
tc.go("%s/%s" % (page_url, quote(sprint_name)))
# see if milestone is set correctly
tc.find('<option selected="selected">\s*milestone2')
# test setting end date, not duration
tc.formvalue('modcomp', 'description', '[http://www.example.com]')
tomorrow = sprint_start + timedelta(days=1)
tc.formvalue('modcomp', 'end', format_datetime(tomorrow, format='iso8601'))
tc.formvalue('modcomp', 'duration', '')
tc.submit('save')
tc.url(page_url)
# duration of the new sprint should be 2
tc.find('"duration">2</td>')
# --- test invalid values when adding sprint ---
# no values, should redirect to list view
tc.formvalue('addsprint', 'name', '')
tc.submit('add')
tc.url(page_url)
# invalid date, should throw an error
tc.formvalue('addsprint', 'name', 'Testsprint 2')
tc.formvalue('addsprint', 'start', '2008 May 13')
tc.formvalue('addsprint', 'duration', '1')
tc.submit('add')
tc.find('Error: Invalid Date')
# no end date or duration
tc.go(page_url)
tc.formvalue('addsprint', 'name', 'Testsprint 2')
yesterday = now() - timedelta(days=3)
tc.formvalue('addsprint', 'start',
format_datetime(yesterday, format='iso8601'))
tc.submit('add')
tc.url(page_url)
开发者ID:djangsters,项目名称:agilo,代码行数:58,代码来源:sprint_admin_test.py
示例8: roundtrip
def roundtrip(locale):
locale = Locale.parse(locale)
formatted = datefmt.format_datetime(t, tzinfo=tz,
locale=locale)
self.assertEqual(expected,
datefmt.parse_date(formatted, tz, locale))
self.assertEqual(formatted,
datefmt.format_datetime(expected, tzinfo=tz,
locale=locale))
开发者ID:trac-ja,项目名称:trac-ja,代码行数:9,代码来源:datefmt.py
示例9: get_timeline_link
def get_timeline_link(self, req, date, label=None, precision='hours'):
iso_date = display_date = format_datetime(date, 'iso8601', req.tz)
fmt = req.session.get('datefmt')
if fmt and fmt != 'iso8601':
display_date = format_datetime(date, fmt, req.tz)
return tag.a(label or iso_date, class_='timeline',
title=_("%(date)s in Timeline", date=display_date),
href=req.href.timeline(from_=iso_date,
precision=precision))
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:9,代码来源:web_ui.py
示例10: get_work_log
def get_work_log(self, pid, username=None, mode='all'):
db = self.env.get_read_db()
cursor = db.cursor()
if mode == 'user':
assert username is not None
cursor.execute('SELECT wl.worker, wl.starttime, wl.endtime, wl.ticket, t.summary, t.status, wl.comment '
'FROM work_log wl '
'JOIN ticket t ON wl.ticket=t.id '
'WHERE t.project_id=%s AND wl.worker=%s '
'ORDER BY wl.lastchange DESC',
(pid, username))
elif mode == 'latest':
cursor.execute('''
SELECT worker, starttime, endtime, ticket, summary, status, comment
FROM (
SELECT wl.worker, wl.starttime, wl.endtime, wl.ticket, wl.comment, wl.lastchange,
MAX(wl.lastchange) OVER (PARTITION BY wl.worker) latest,
t.summary, t.status
FROM work_log wl
JOIN ticket t ON wl.ticket=t.id AND project_id=%s
) wll
WHERE lastchange=latest
ORDER BY lastchange DESC, worker
''', (pid,))
else:
cursor.execute('SELECT wl.worker, wl.starttime, wl.endtime, wl.ticket, t.summary, t.status, wl.comment '
'FROM work_log wl '
'JOIN ticket t ON wl.ticket=t.id '
'WHERE t.project_id=%s '
'ORDER BY wl.lastchange DESC, wl.worker',
(pid,))
rv = []
for user,starttime,endtime,ticket,summary,status,comment in cursor:
started = to_datetime(starttime)
if endtime != 0:
finished = to_datetime(endtime)
delta = 'Worked for %s (between %s and %s)' % (
pretty_timedelta(started, finished),
format_datetime(started), format_datetime(finished))
else:
finished = 0
delta = 'Started %s ago (%s)' % (
pretty_timedelta(started),
format_datetime(started))
rv.append({'user': user,
'starttime': started,
'endtime': finished,
'delta': delta,
'ticket': ticket,
'summary': summary,
'status': status,
'comment': comment})
return rv
开发者ID:lexqt,项目名称:EduTracTicketWorklog,代码行数:56,代码来源:manager.py
示例11: get_timeline_link
def get_timeline_link(self, req, date, label=None, precision="hours"):
iso_date = display_date = format_datetime(date, "iso8601", req.tz)
fmt = req.session.get("datefmt")
if fmt and fmt != "iso8601":
display_date = format_datetime(date, fmt, req.tz)
return tag.a(
label or iso_date,
class_="timeline",
title=_("%(date)s in Timeline", date=display_date),
href=req.href.timeline(from_=iso_date, precision=precision),
)
开发者ID:gdgkyoto,项目名称:kyoto-gtug,代码行数:11,代码来源:web_ui.py
示例12: test_with_babel_format
def test_with_babel_format(self):
tz = datefmt.timezone("GMT +2:00")
t = datetime.datetime(2010, 8, 28, 11, 45, 56, 123456, tz)
for f in ("short", "medium", "long", "full"):
self.assertEqual("2010-08-28", datefmt.format_date(t, f, tz, "iso8601"))
self.assertEqual("11:45", datefmt.format_time(t, "short", tz, "iso8601"))
self.assertEqual("2010-08-28T11:45", datefmt.format_datetime(t, "short", tz, "iso8601"))
self.assertEqual("11:45:56", datefmt.format_time(t, "medium", tz, "iso8601"))
self.assertEqual("2010-08-28T11:45:56", datefmt.format_datetime(t, "medium", tz, "iso8601"))
for f in ("long", "full"):
self.assertEqual("11:45:56+02:00", datefmt.format_time(t, f, tz, "iso8601"))
self.assertEqual("2010-08-28T11:45:56+02:00", datefmt.format_datetime(t, f, tz, "iso8601"))
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:12,代码来源:datefmt.py
示例13: test_format_datetime_gmt01
def test_format_datetime_gmt01(self):
gmt01 = datefmt.FixedOffset(60, 'GMT +1:00')
t = datetime.datetime(1970,1,1,1,0,23,0,gmt01)
expected = '1970-01-01T01:00:23+0100'
self.assertEqual(datefmt.format_datetime(t, '%Y-%m-%dT%H:%M:%S%z',
gmt01), expected)
self.assertEqual(datefmt.format_datetime(t, 'iso8601',
gmt01), expected)
self.assertEqual(datefmt.format_datetime(t, 'iso8601date', gmt01),
expected.split('T')[0])
self.assertEqual(datefmt.format_datetime(t, 'iso8601time', gmt01),
expected.split('T')[1])
开发者ID:gdgkyoto,项目名称:kyoto-gtug,代码行数:12,代码来源:datefmt.py
示例14: test_format_compatibility
def test_format_compatibility(self):
tz = datefmt.timezone("GMT +2:00")
t = datetime.datetime(2010, 8, 28, 11, 45, 56, 123456, datefmt.utc)
tz_t = datetime.datetime(2010, 8, 28, 13, 45, 56, 123456, tz)
en_US = Locale.parse("en_US")
# Converting default format to babel's format
self.assertEqual("Aug 28, 2010 1:45:56 PM", datefmt.format_datetime(t, "%x %X", tz, en_US))
self.assertEqual("Aug 28, 2010", datefmt.format_datetime(t, "%x", tz, en_US))
self.assertEqual("1:45:56 PM", datefmt.format_datetime(t, "%X", tz, en_US))
self.assertEqual("Aug 28, 2010", datefmt.format_date(t, "%x", tz, en_US))
self.assertEqual("1:45:56 PM", datefmt.format_time(t, "%X", tz, en_US))
开发者ID:moreati,项目名称:trac-gitsvn,代码行数:12,代码来源:datefmt.py
示例15: process_request
def process_request(self, req):
req.perm.assert_permission('REQUIREMENT_VIEW')
if req.perm.has_permission('REQUIREMENT_CREATE'):
req.hdf['report.add_requirement_href'] = req.href.newrequirement()
req.hdf['report.edit_fphyp_href'] = req.href('editdict', 'fp')
db = self.env.get_db_cnx()
report = req.args.get('report', '')
# only for use in reports showing (nearly) all requirements
if (report == '1' or report == '2' or report == '3'):
# flag the report to use the validation button
req.hdf['report.is_all_reqs_report'] = 1
myreq = Requirement(self.env)
req.hdf['report.currently_validated'] = \
myreq.get_current_reqs_validated()
validation_time = myreq.get_most_recent_validation()
if validation_time is not None:
req.hdf['report.latest_validation'] = \
format_datetime(validation_time)
else:
req.hdf['report.latest_validation'] = '(None)'
# get the value from the validation button if it exists:
if req.method == 'POST':
validate = req.args.get('ValidateSubmit', '')
if validate == 'Validate':
# set this flag...
# ... and validate the current set of requirements:
if myreq.validate_requirements():
req.hdf['report.validate'] = 2
req.hdf['report.latest_validation'] = format_datetime()
else:
req.hdf['report.validate'] = 1
if report is not '':
add_link(req, 'up', req.href('requirements', 'report'))
resp = self._render_view(req, db, report)
if not resp:
return None
template, content_type = resp
if content_type:
return resp
add_stylesheet(req, 'hw/css/req_report.css')
return 'req_report.cs', None
开发者ID:cyphactor,项目名称:lifecyclemanager,代码行数:52,代码来源:report.py
示例16: test_format_datetime_utc
def test_format_datetime_utc(self):
t = datetime.datetime(1970, 1, 1, 1, 0, 23, 0, datefmt.utc)
expected = '1970-01-01T01:00:23Z'
self.assertEqual(datefmt.format_datetime(t, '%Y-%m-%dT%H:%M:%SZ',
datefmt.utc), expected)
self.assertEqual(datefmt.format_datetime(t, 'iso8601',
datefmt.utc), expected)
self.assertEqual(datefmt.format_datetime(t, 'iso8601date',
datefmt.utc),
expected.split('T')[0])
self.assertEqual(datefmt.format_datetime(t, 'iso8601time',
datefmt.utc),
expected.split('T')[1])
开发者ID:wiraqutra,项目名称:photrackjp,代码行数:13,代码来源:datefmt.py
示例17: _get_sprint
def _get_sprint(self, req, sprint_name):
"""Retrieve the Sprint for the given name"""
get_sprint = SprintController.GetSprintCommand(self.env,
sprint=sprint_name)
sprint = SprintController(self.env).process_command(get_sprint)
# we need to convert sprint dates into local timezone
sprint.start = format_datetime(sprint.start, tzinfo=req.tz)
sprint.end = format_datetime(sprint.end, tzinfo=req.tz)
if sprint.team is None:
msg = _("No Team has been assigned to this Sprint...")
if not msg in req.chrome['warnings']:
add_warning(req, msg)
return sprint
开发者ID:djangsters,项目名称:agilo,代码行数:13,代码来源:web_ui.py
示例18: _do_list
def _do_list(self):
print_table([(m.name, m.due and
format_date(m.due, console_date_format),
m.completed and
format_datetime(m.completed, console_datetime_format))
for m in model.Milestone.select(self.env)],
[_("Name"), _("Due"), _("Completed")])
开发者ID:Stackato-Apps,项目名称:bloodhound,代码行数:7,代码来源:admin.py
示例19: pretty_release_time
def pretty_release_time(self, req, user):
"""Convenience method for formatting lock time to string."""
ts_release = self.release_time(user)
if ts_release is None:
return None
return format_datetime(to_datetime(
self.release_time(user)), tzinfo=req.tz)
开发者ID:lkraav,项目名称:trachacks,代码行数:7,代码来源:guard.py
示例20: _render_history
def _render_history(self, req, db, page):
"""Extract the complete history for a given page and stores it in the
HDF.
This information is used to present a changelog/history for a given
page.
"""
req.perm.assert_permission('WIKI_VIEW')
if not page.exists:
raise TracError, "Page %s does not exist" % page.name
self._set_title(req, page, u'历史')
history = []
for version, t, author, comment, ipnr in page.get_history():
history.append({
'url': req.href.wiki(page.name, version=version),
'diff_url': req.href.wiki(page.name, version=version,
action='diff'),
'version': version,
'time': format_datetime(t),
'time_delta': pretty_timedelta(t),
'author': author,
'comment': wiki_to_oneliner(comment or '', self.env, db),
'ipaddr': ipnr
})
req.hdf['wiki.history'] = history
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:28,代码来源:web_ui.py
注:本文中的trac.util.datefmt.format_datetime函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论