##// END OF EJS Templates
py3: work around bytes/unicode divergence in parsedate()
Yuya Nishihara -
r34358:b76937fa default
parent child Browse files
Show More
@@ -2056,12 +2056,12 b' def parsedate(date, formats=None, bias=N'
2056 The date may be a "unixtime offset" string or in one of the specified
2056 The date may be a "unixtime offset" string or in one of the specified
2057 formats. If the date already is a (unixtime, offset) tuple, it is returned.
2057 formats. If the date already is a (unixtime, offset) tuple, it is returned.
2058
2058
2059 >>> parsedate(b' today ') == parsedate(\
2059 >>> parsedate(b' today ') == parsedate(
2060 datetime.date.today().strftime('%b %d'))
2060 ... datetime.date.today().strftime('%b %d').encode('ascii'))
2061 True
2061 True
2062 >>> parsedate(b'yesterday ') == parsedate((datetime.date.today() -\
2062 >>> parsedate(b'yesterday ') == parsedate(
2063 datetime.timedelta(days=1)\
2063 ... (datetime.date.today() - datetime.timedelta(days=1)
2064 ).strftime('%b %d'))
2064 ... ).strftime('%b %d').encode('ascii'))
2065 True
2065 True
2066 >>> now, tz = makedate()
2066 >>> now, tz = makedate()
2067 >>> strnow, strtz = parsedate(b'now')
2067 >>> strnow, strtz = parsedate(b'now')
@@ -2083,10 +2083,12 b' def parsedate(date, formats=None, bias=N'
2083 if date == 'now' or date == _('now'):
2083 if date == 'now' or date == _('now'):
2084 return makedate()
2084 return makedate()
2085 if date == 'today' or date == _('today'):
2085 if date == 'today' or date == _('today'):
2086 date = datetime.date.today().strftime('%b %d')
2086 date = datetime.date.today().strftime(r'%b %d')
2087 date = encoding.strtolocal(date)
2087 elif date == 'yesterday' or date == _('yesterday'):
2088 elif date == 'yesterday' or date == _('yesterday'):
2088 date = (datetime.date.today() -
2089 date = (datetime.date.today() -
2089 datetime.timedelta(days=1)).strftime('%b %d')
2090 datetime.timedelta(days=1)).strftime(r'%b %d')
2091 date = encoding.strtolocal(date)
2090
2092
2091 try:
2093 try:
2092 when, offset = map(int, date.split(' '))
2094 when, offset = map(int, date.split(' '))
@@ -69,7 +69,7 b" testmod('mercurial.templatefilters')"
69 testmod('mercurial.templater')
69 testmod('mercurial.templater')
70 testmod('mercurial.ui')
70 testmod('mercurial.ui')
71 testmod('mercurial.url')
71 testmod('mercurial.url')
72 testmod('mercurial.util', py3=False) # py3: multiple bytes/unicode issues
72 testmod('mercurial.util')
73 testmod('mercurial.util', testtarget='platform')
73 testmod('mercurial.util', testtarget='platform')
74 testmod('hgext.convert.convcmd')
74 testmod('hgext.convert.convcmd')
75 testmod('hgext.convert.cvsps')
75 testmod('hgext.convert.cvsps')
General Comments 0
You need to be logged in to leave comments. Login now