Commit Graph

42 Commits

Author SHA1 Message Date
Ezio Melotti c2077b0d9b #11565: Fix several typos. Patch by Piotr Kasprzyk. 2011-03-16 12:34:31 +02:00
Ronald Oussoren 9545a23c7f In a number of places code still revers
to "sys.platform == 'mac'" and that is
dead code because it refers to a platform
that is no longer supported (and hasn't been
supported for several releases).

Fixes issue #7908 for the trunk.
2010-05-05 19:09:31 +00:00
Ezio Melotti aa98058cc4 use assert[Not]In where appropriate 2010-01-23 23:04:36 +00:00
Ezio Melotti e304852e21 #7342: make sure that the datetime object in test_fraction always has a number of microseconds != 0 2009-12-13 18:54:53 +00:00
Benjamin Peterson 7582ec36b2 use 'is' instead of id() 2009-10-26 22:51:16 +00:00
Benjamin Peterson 5c8da86f3a convert usage of fail* to assert* 2009-06-30 22:57:08 +00:00
Skip Montanaro fc070d2731 add %f format to datetime - issue 1158 2008-03-15 16:04:45 +00:00
Brett Cannon f7188cefb3 Make _strptime.TimeRE().pattern() use ``\s+`` for matching whitespace instead
of ``\s*``.  This prevents patterns from "stealing" bits from other patterns in
order to make a match work.

Closes bug #1730389.  Will be backported.
2007-06-03 23:13:41 +00:00
Brett Cannon c7a2e4656e Fix the test for recreating the locale cache object by not worrying about if
one of the test locales cannot be set.
2007-04-01 19:46:19 +00:00
Brett Cannon c69066501b time.strptime's caching of its locale object was being recreated when the
locale changed but not used during the function call it was recreated during.

The test in this checkin is untested (OS X does not have the proper locale
support for me to test), although the fix for the bug this deals with
was tested by the OP (#1290505).  Once the buildbots verify the test at least
doesn't fail it becomes a backport candidate.
2007-04-01 18:47:27 +00:00
Brett Cannon 07e1db317d Fix time.strptime's %U support. Basically rewrote the algorithm to be more
generic so that one only has to shift certain values based on whether the week
was specified to start on Monday or Sunday.  Cut out a lot of edge case code
compared to the previous version.  Also broke algorithm out into its own
function (that is private to the module).

Fixes bug #1643943 (thanks Biran Nahas for the report).
2007-01-25 20:22:02 +00:00
Brett Cannon 5d0bf9446b Change time.strptime() to raise ValueError whenever there is an error in the
format string.  Before exceptions generated by the internal code propagated up
to the user and were not helpful.

Closes bug #1340337.
2005-11-02 23:04:26 +00:00
Brett Cannon a783d06f8c Clear out the regex cache when the TimeRE cache is invalidated by a locale
change.

Fixes bug #1290505.
2005-09-15 02:34:56 +00:00
Brett Cannon 14adbe77b5 Fix bug of implementation of algorithm for calculating the date from year, week
of the year, and day of the week.  Was not taking into consideration properly
the issue of when %U is used for the week of the year but the year starts on
Monday.

Closes bug #1045381 again.
2004-10-28 04:49:21 +00:00
Brett Cannon 8abcc5d533 Add support for %U and %W to contribute to calculating the date when the year
and day of the week are specified.

Closes bug #1045381.
2004-10-18 01:37:57 +00:00
Brett Cannon 4f35c71543 Locale data that contains regex metacharacters are now properly escaped.
Closes bug #1039270.
2004-10-06 02:11:37 +00:00
Brett Cannon 80e1f06594 It helps when doing checks if something is in a tuple of strings that if you
put everything in the tuple in caps to use str.upper() instead of str.lower().
2004-07-14 00:43:51 +00:00
Brett Cannon fdf7449ad2 Fix test case for when time.tzname[0] is either UTC or GMT. Also have test
output more telling details when there is a failure.
2004-07-12 19:34:02 +00:00
Raymond Hettinger a690a9967e * Migrate set() and frozenset() from the sandbox.
* Install the unittests, docs, newsitem, include file, and makefile update.
* Exercise the new functions whereever sets.py was being used.

Includes the docs for libfuncs.tex.  Separate docs for the types are
forthcoming.
2003-11-16 16:17:49 +00:00
Brett Cannon 953c6f508b Make sure parentheses are escaped when used in the format string.
Closes bug #796149 .  Will be backported.
2003-08-29 02:28:54 +00:00
Brett Cannon c83124ab79 Fix bug in test_bad_timezone where test was assuming locale knew of PDT. 2003-08-11 19:06:13 +00:00
Brett Cannon 5187a3bcdb Fix handling of bad locale setup where time.tzname[0] == time.tzname[1] and
time.daylight is true.  Add an explicit test for this situation.

Fixed some wording in docstrings.
2003-08-11 07:24:05 +00:00
Brett Cannon 474335ce17 Re-introduce caching of TimeRE and compiled regexes with added thread-safety.
Also remove now unnecessary property attributes for thread safety
(no longer have lazy attributes) and code simplicity reasons.

Timezone storage has been reworked to be simpler and more flexible.  All values
in LocaleTime instances are lower-cased.  This is all done to simplify the
module.

The module now assumes nothing beyond the strptime function will be exposed for
general use beyond providing functionality for strptime.
2003-08-05 04:02:49 +00:00
Brett Cannon 175ddb5b30 Remove caching of TimeRE (and thus LocaleTime) instance. Error was being
caught when executing test_strptime, test_logging, and test_time in that order
when the testing of "%c" occured.  Suspect the cache was not being recreated
(the test passed when test_logging was forced to re-establish the locale).
2003-07-24 06:27:17 +00:00
Brett Cannon d1deac06e7 Fix error in test of not comparing against 0 item of a list 2003-07-22 21:07:16 +00:00
Brett Cannon cde2200ff2 Fixes bug of timezone value being left as -1 when ``time.tzname[0] ==
time.tzname[1] and not time.daylight`` is true when it should only when
time.daylight is true.  Tests are also fixed.

Closes bug #763047 and its cohort #763052.
2003-07-03 19:59:57 +00:00
Neal Norwitz 3106817c68 Fix typo in error message 2003-06-30 19:22:12 +00:00
Raymond Hettinger b4e9986782 Removed invalid test.
Analysis by Bob Halley:

  The test seems to expect that if time.daylight is true, then the
  is_dst field of the tm structure will be 1 too.  But this isn't
  the case, since daylight is true if the timezone does DST, *not*
  if DST is in effect.
2003-06-29 15:57:50 +00:00
Brett Cannon 172d9ef47e Beefed up timezone support. UTC and GMT are now always recognized timezones
with values of 0.  Also now check time.daylight to see if time.tzname[1]
should be used in timezone checking.
2003-05-11 06:23:36 +00:00
Walter Dörwald 21d3a32b99 Combine the functionality of test_support.run_unittest()
and test_support.run_classtests() into run_unittest()
and use it wherever possible.

Also don't use "from test.test_support import ...", but
"from test import test_support" in a few spots.

From SF patch #662807.
2003-05-01 17:45:56 +00:00
Brett Cannon 2b6dfec1cc Raise a ValueError when there is data that was not covered in the format string. Done to match behavior of pre-existing C-based strptime implementations. 2003-04-28 21:30:13 +00:00
Brett Cannon 1e91d8eb03 Make _strptime escape regex syntax in format string to prevent use in internal regex. 2003-04-19 04:00:56 +00:00
Raymond Hettinger 1fdb633530 SF patch #691928: Use datetime in _strptime
Contributed by Brett Cannon.

To prevent code duplication, I patched _strptime to use datetime's date
object to do Julian day, Gregorian, and day of the week calculations.

Patch also includes new regression tests to test results and the
calculation gets triggered.

Very minor comment changes and the contact email are also changed.
2003-03-09 07:44:42 +00:00
Tim Peters 08e54270f2 SF patch 670012: Compatibility changes for _strptime.py.
Patch from Brett Cannon:

    First, the 'y' directive now handles [00, 68] as a suffix for the
    21st century while [69, 99] is treated as the suffix for the 20th
    century (this is for Open Group compatibility).

    strptime now returns default values that make it a valid date ...

    the ability to pass in a regex object to use instead of a format
    string (and the inverse ability to have strptime return a regex object)
    has been removed. This is in preparation for a future patch that will
    add some caching internally to get a speed boost.
2003-01-18 03:53:49 +00:00
Neal Norwitz 490602d629 Fix julian day problem with strptime. Note: XXX about using 0, suggestions? 2002-12-26 16:19:52 +00:00
Martin v. Löwis e16e01fac6 Patch #639112: fixes for None locale and tz. 2002-11-27 08:30:25 +00:00
Barry Warsaw 4d895fa125 Brett's fixes for various bugs and coding issues. Closes SF patch #
593560, with some minor cleanups, line folding and whitespace
normalization by Barry.
2002-09-23 22:46:49 +00:00
Guido van Rossum 472c5229c4 Delete the %c test from test_date_time() untill Brett Cannon has time
to fix it.  (It fails when the day of the month is a 1-digit number,
because %c produces space+digit there, while strptime seems to expect
zero+digit somehow.)
2002-09-03 21:10:10 +00:00
Barry Warsaw 375e0eeacc The test I saw failing this morning just happened to be run at 8am
localtime, which in -0400 is 12 noon GMT.  The bug boiled down to
broken conversion of 12 PM to hour 12 for the '%I %p' format string.

Added a test for this specific condition: Strptime12AMPMTests.  Fix to
_strptime.py coming momentarily.
2002-08-29 15:25:04 +00:00
Guido van Rossum a5ce2e8c17 Standardize behavior: no docstrings in test functions; add a proper
test_main() that creates a suite and runs it.  Don't mess with sys.path!!!
2002-08-22 19:57:50 +00:00
Tim Peters 469cdad822 Whitespace normalization. 2002-08-08 20:19:19 +00:00
Guido van Rossum 00efe7e798 Pure Python strptime implementation by Brett Cannon. See SF patch 474274.
Also adds tests.
2002-07-19 17:04:46 +00:00