summaryrefslogtreecommitdiff
path: root/python-dateformat.spec
blob: dc8b1a9756d257c8fbd60654555ef343d56373cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
%global _empty_manifest_terminate_build 0
Name:		python-dateformat
Version:	0.9.7
Release:	1
Summary:	Parse and format dates quickly
License:	MIT
URL:		https://github.com/stestagg/dateformat
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/5d/58/05eef6d4a106ad7c64c1f3be19a301ddf384d599e9ca4a53f9ea05b60a5e/dateformat-0.9.7.tar.gz
BuildArch:	noarch


%description
        

        `dateformat` does two things:  turn `datetime` objects into strings, and turn strings into `datetime` objects.

        It's goal is to do these things simply and well, and to satisfy the following criteria:

        

         * Be fast enough (see below for benchmarks)

         * Handle a variety of date formats from multiple sources

         * Parse and format dates in many timezones and with many timezone offsets

         * Represent the expected format in a way that a non-technical person may understand

         * Be explicit about the expected format to prevent heuristic errors

        

        > "But why another date library?"

        

        There isn't currently a python library I've been able to find that matches these 

        requirements well enough for my use-cases.  [`Arrow`](http://arrow.readthedocs.io/en/latest/)

         comes closest, but still isn't quite suitable performance-wise.

        

        # Usage

        

        All functionality is based around DateFormat() objects:

        

        ### `def __init__(self, spec, is_24hour=None)`

        

        create a dateformat object from the provided spec string.

        

        ```

        >>> from dateformat import DateFormat

        

        >>> date_format = DateFormat("YYYY-MM-DD hh:mm:ss.SSSS+HH:MM")

        ```

        

        If `is_24hour` is not provided, the format will be in 12-hour mode if an am/pm 

        part is present in the spec, otherwise, dates will be in 24-hour mode.

        

        DateFormat instances have two methods:

        

        ### `def parse(self, data)`

        

        Parse a string(`data`) containing a date into a datetime object.

        

        ```

        >>> date = date_format.parse("2017-06-03 15:32:00.2364-02:00")

        datetime.datetime(2017, 6, 3, 15, 32, 0, 236400, tzinfo=datetime.timezone(datetime.timedelta(-1, 79200)))

        ```

        

        ### `def format(self, date)`

        

        Format the passed in `datetime.datetime` object (`date`) as a string:

        

        ```

        >>> print(date_format.format(date))

        2017-06-03 15:32:00.2364-02:00

        ```

        

        ## Timezones

        

        If any part of the format provides a timezone, or UTC offset, then parsing 

        produces dates with a timezone indicating the relevant UTC offset.

        

        Likewise, if a dateformat has a timezone part, then dates passed to `.format()`

        must include a tzinfo value.

        

        If pytz is available, then some level of named timezone support is provided.

        

        ## Leading zeros

        

        All numeric parts of the date format are zero-padded to the number of characters

        in the spec.  I.e.  'DD' means that the day of the month is zero-padded to 2-digits.

        

        During parsing, a missing leading zero is usually ignored, but if there is no separator

        between parts (for example:  YYYYMMDD), then a missing leading zero will cause an error or bad value.

        

        Currently, all formatted dates are zero-padded, in the future, this may be controllable.

        

        ## Date format specification

        | Part | Example | Description |

        |---------|---------|---------------|

        | `+HHMM` | -0515 | A UTC offset provided as a 2-digit hour, and 2-digit minute, with no separator |

        | `+HH:MM` | -05:15 | A UTC offset provided as a 2-digit hour, and 2-digit minute, with a ':' separator |

        | `+HH` | -05 | A UTC offset provided as a 2-digit hour only |

        | `Dddddd` | Monday | The full locale-specific day of the week (Note, this value is ignored during date parsing, but added during date format) |

        | `Ddd` | Mon | The locale-specific short name for the day of the week (Ignored during parsing) |

        | `DD` | 05 | The zero-padded day of the month. |

        | `MMMMM` | September | Month as locale’s full name |

        | `MMM` | Sep | Month as locale’s abbreviated name |

        | `YYYY` | 2017 | Year with century as a number |

        | `YY` | 17 | Year without century as a zero-padded number |

        | `hh` | 09 | Hour as a zero-padded number |

        | `mm` | 06 | Minute as a zero-padded number |

        | `ss` | 45 | Second as a zero-padded number |

        | `SSSSSS` | 123456 | Microsecond as a zero-padded decimal number |

        | `SSSS`   | 1234 | 100-microseconds as a zero-padded number |

        | `SSS` | 123 | milliseconds as a zero-padded number |

        | `SS` | 12 | 10-milliseconds as a zero-padded number |

        | `am` `Am` `AM` `pm` `Pm` `PM` | am | either AM or PM depending on the hour.  `.format()` matches the case of the spec.  If present, the dateformat will default to 12-hour mode |

        | `of` | | Ignored during parsing, added during formtting |

        | `st` | th | The appropriate suffix for the day of the month, for example '1_st_ July', '2_nd_ March' |

        | `␣` | T | (Unicode OPEN BOX - U+2423) Matches either the character 'T' or a space ' '.  During formatting, 'T' is always used (this is provided to improve flexibility when parsing iso8601 formats) |

        | space | | Matches one or more spaces during parsing.  During formatting, one space will be output |

        | any of `:/-.,TZ()` | | Ignored during parsing, output as-is during formatting |

        

        

        # Examples

        

        | Format                   | Example                |

        |--------------------------|------------------------|

        | `YYYY-MM-DDThh:mm:ss`    | 2017-06-06T09:45:15    |

        | `YYYYMMDDhhmmss`         | 20170606094515         |

        | `YYYYMMDDhhmmss.SSSSSSZ` | 20170606094515.123456Z |

        | `MM/DD/YY hh:mm+HHMM`    | 06/06/17 09:45-0500    |

        

        

        # Library comparison

        

        ## dateformat ⇄ datetime (builtin python module)

        

        Dateformat is *not* trying to be a replacement for the builtin datetime module.  `datetime.datetime` objects are used as the input/output to the parsing and formatting methods.

        

        It is designed as a replacement for the  `datetime.datetime.strftime` and `datetime.datetime.strptime` methods, providing:

        

         * better timezone handling

         * a simpler/more common syntax for specifying the date formats

         * slightly faster parsing

        

        ## dateformat ⇄ dateutil.parser.parse()

        

        `dateutil.parser.parse`'s intent is to turn a string in an unknown format into a date.  It does that by using a variety of heuristics to try to figure out the format the date has been expressed in.

        

        This approach is highly useful, and very flexible, but suffers from a couple of drawbacks that dateformat doesn't have:

        

         * There is ambiguity about what date will be produced from a given string, there are situations where that risk cannot be accepted, and it's important for the system to only accept a certain date format

         * Because of all the work that dateutil is doing to work out the format used, it's fairly slow, at just under 10x slower than `strptime`, this is very noticable over 10s - 100s thousands of dates.

        

        ## dateformat ⇄ arrow

        

        arrow is the closest to the way dateformat works, the syntax for describing dates is very similar. Unfortunately, arrow constructs its parser every time a date is parsed, creating a significant overhead when parsing each date.

        

        ## dateformat ⇄ iso8601 / ciso8601

        

        ciso8601 is _really_ fast.  Unfortunately both these libraries only handle a single date format, so are not useful in this situation.

        

        # Benchmarks

        

        the `benchmark/` dir contains some simple scripts to show how the relative libraries perform at parsing and formatting dates.

        

        Running on a 2016 macbook pro, on Python 3.6.3 gave the following results (best of 3 runs):

        

        (Please note, the parse time chart y-axis has been clamped to 1s, but dateparser took 16s to complete)

        

        ![chart showing relative date parse performance](https://github.com/stestagg/dateformat/raw/master/benchmark/parse_times.png)

        

        ![chart showing relative date format performance](https://github.com/stestagg/dateformat/raw/master/benchmark/format_times.png)

        

        
Keywords: date time parsing formatting datetime
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Provides-Extra: test


%package -n python3-dateformat
Summary:	Parse and format dates quickly
Provides:	python-dateformat
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-dateformat
        

        `dateformat` does two things:  turn `datetime` objects into strings, and turn strings into `datetime` objects.

        It's goal is to do these things simply and well, and to satisfy the following criteria:

        

         * Be fast enough (see below for benchmarks)

         * Handle a variety of date formats from multiple sources

         * Parse and format dates in many timezones and with many timezone offsets

         * Represent the expected format in a way that a non-technical person may understand

         * Be explicit about the expected format to prevent heuristic errors

        

        > "But why another date library?"

        

        There isn't currently a python library I've been able to find that matches these 

        requirements well enough for my use-cases.  [`Arrow`](http://arrow.readthedocs.io/en/latest/)

         comes closest, but still isn't quite suitable performance-wise.

        

        # Usage

        

        All functionality is based around DateFormat() objects:

        

        ### `def __init__(self, spec, is_24hour=None)`

        

        create a dateformat object from the provided spec string.

        

        ```

        >>> from dateformat import DateFormat

        

        >>> date_format = DateFormat("YYYY-MM-DD hh:mm:ss.SSSS+HH:MM")

        ```

        

        If `is_24hour` is not provided, the format will be in 12-hour mode if an am/pm 

        part is present in the spec, otherwise, dates will be in 24-hour mode.

        

        DateFormat instances have two methods:

        

        ### `def parse(self, data)`

        

        Parse a string(`data`) containing a date into a datetime object.

        

        ```

        >>> date = date_format.parse("2017-06-03 15:32:00.2364-02:00")

        datetime.datetime(2017, 6, 3, 15, 32, 0, 236400, tzinfo=datetime.timezone(datetime.timedelta(-1, 79200)))

        ```

        

        ### `def format(self, date)`

        

        Format the passed in `datetime.datetime` object (`date`) as a string:

        

        ```

        >>> print(date_format.format(date))

        2017-06-03 15:32:00.2364-02:00

        ```

        

        ## Timezones

        

        If any part of the format provides a timezone, or UTC offset, then parsing 

        produces dates with a timezone indicating the relevant UTC offset.

        

        Likewise, if a dateformat has a timezone part, then dates passed to `.format()`

        must include a tzinfo value.

        

        If pytz is available, then some level of named timezone support is provided.

        

        ## Leading zeros

        

        All numeric parts of the date format are zero-padded to the number of characters

        in the spec.  I.e.  'DD' means that the day of the month is zero-padded to 2-digits.

        

        During parsing, a missing leading zero is usually ignored, but if there is no separator

        between parts (for example:  YYYYMMDD), then a missing leading zero will cause an error or bad value.

        

        Currently, all formatted dates are zero-padded, in the future, this may be controllable.

        

        ## Date format specification

        | Part | Example | Description |

        |---------|---------|---------------|

        | `+HHMM` | -0515 | A UTC offset provided as a 2-digit hour, and 2-digit minute, with no separator |

        | `+HH:MM` | -05:15 | A UTC offset provided as a 2-digit hour, and 2-digit minute, with a ':' separator |

        | `+HH` | -05 | A UTC offset provided as a 2-digit hour only |

        | `Dddddd` | Monday | The full locale-specific day of the week (Note, this value is ignored during date parsing, but added during date format) |

        | `Ddd` | Mon | The locale-specific short name for the day of the week (Ignored during parsing) |

        | `DD` | 05 | The zero-padded day of the month. |

        | `MMMMM` | September | Month as locale’s full name |

        | `MMM` | Sep | Month as locale’s abbreviated name |

        | `YYYY` | 2017 | Year with century as a number |

        | `YY` | 17 | Year without century as a zero-padded number |

        | `hh` | 09 | Hour as a zero-padded number |

        | `mm` | 06 | Minute as a zero-padded number |

        | `ss` | 45 | Second as a zero-padded number |

        | `SSSSSS` | 123456 | Microsecond as a zero-padded decimal number |

        | `SSSS`   | 1234 | 100-microseconds as a zero-padded number |

        | `SSS` | 123 | milliseconds as a zero-padded number |

        | `SS` | 12 | 10-milliseconds as a zero-padded number |

        | `am` `Am` `AM` `pm` `Pm` `PM` | am | either AM or PM depending on the hour.  `.format()` matches the case of the spec.  If present, the dateformat will default to 12-hour mode |

        | `of` | | Ignored during parsing, added during formtting |

        | `st` | th | The appropriate suffix for the day of the month, for example '1_st_ July', '2_nd_ March' |

        | `␣` | T | (Unicode OPEN BOX - U+2423) Matches either the character 'T' or a space ' '.  During formatting, 'T' is always used (this is provided to improve flexibility when parsing iso8601 formats) |

        | space | | Matches one or more spaces during parsing.  During formatting, one space will be output |

        | any of `:/-.,TZ()` | | Ignored during parsing, output as-is during formatting |

        

        

        # Examples

        

        | Format                   | Example                |

        |--------------------------|------------------------|

        | `YYYY-MM-DDThh:mm:ss`    | 2017-06-06T09:45:15    |

        | `YYYYMMDDhhmmss`         | 20170606094515         |

        | `YYYYMMDDhhmmss.SSSSSSZ` | 20170606094515.123456Z |

        | `MM/DD/YY hh:mm+HHMM`    | 06/06/17 09:45-0500    |

        

        

        # Library comparison

        

        ## dateformat ⇄ datetime (builtin python module)

        

        Dateformat is *not* trying to be a replacement for the builtin datetime module.  `datetime.datetime` objects are used as the input/output to the parsing and formatting methods.

        

        It is designed as a replacement for the  `datetime.datetime.strftime` and `datetime.datetime.strptime` methods, providing:

        

         * better timezone handling

         * a simpler/more common syntax for specifying the date formats

         * slightly faster parsing

        

        ## dateformat ⇄ dateutil.parser.parse()

        

        `dateutil.parser.parse`'s intent is to turn a string in an unknown format into a date.  It does that by using a variety of heuristics to try to figure out the format the date has been expressed in.

        

        This approach is highly useful, and very flexible, but suffers from a couple of drawbacks that dateformat doesn't have:

        

         * There is ambiguity about what date will be produced from a given string, there are situations where that risk cannot be accepted, and it's important for the system to only accept a certain date format

         * Because of all the work that dateutil is doing to work out the format used, it's fairly slow, at just under 10x slower than `strptime`, this is very noticable over 10s - 100s thousands of dates.

        

        ## dateformat ⇄ arrow

        

        arrow is the closest to the way dateformat works, the syntax for describing dates is very similar. Unfortunately, arrow constructs its parser every time a date is parsed, creating a significant overhead when parsing each date.

        

        ## dateformat ⇄ iso8601 / ciso8601

        

        ciso8601 is _really_ fast.  Unfortunately both these libraries only handle a single date format, so are not useful in this situation.

        

        # Benchmarks

        

        the `benchmark/` dir contains some simple scripts to show how the relative libraries perform at parsing and formatting dates.

        

        Running on a 2016 macbook pro, on Python 3.6.3 gave the following results (best of 3 runs):

        

        (Please note, the parse time chart y-axis has been clamped to 1s, but dateparser took 16s to complete)

        

        ![chart showing relative date parse performance](https://github.com/stestagg/dateformat/raw/master/benchmark/parse_times.png)

        

        ![chart showing relative date format performance](https://github.com/stestagg/dateformat/raw/master/benchmark/format_times.png)

        

        
Keywords: date time parsing formatting datetime
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Provides-Extra: test


%package help
Summary:	Development documents and examples for dateformat
Provides:	python3-dateformat-doc
%description help
        

        `dateformat` does two things:  turn `datetime` objects into strings, and turn strings into `datetime` objects.

        It's goal is to do these things simply and well, and to satisfy the following criteria:

        

         * Be fast enough (see below for benchmarks)

         * Handle a variety of date formats from multiple sources

         * Parse and format dates in many timezones and with many timezone offsets

         * Represent the expected format in a way that a non-technical person may understand

         * Be explicit about the expected format to prevent heuristic errors

        

        > "But why another date library?"

        

        There isn't currently a python library I've been able to find that matches these 

        requirements well enough for my use-cases.  [`Arrow`](http://arrow.readthedocs.io/en/latest/)

         comes closest, but still isn't quite suitable performance-wise.

        

        # Usage

        

        All functionality is based around DateFormat() objects:

        

        ### `def __init__(self, spec, is_24hour=None)`

        

        create a dateformat object from the provided spec string.

        

        ```

        >>> from dateformat import DateFormat

        

        >>> date_format = DateFormat("YYYY-MM-DD hh:mm:ss.SSSS+HH:MM")

        ```

        

        If `is_24hour` is not provided, the format will be in 12-hour mode if an am/pm 

        part is present in the spec, otherwise, dates will be in 24-hour mode.

        

        DateFormat instances have two methods:

        

        ### `def parse(self, data)`

        

        Parse a string(`data`) containing a date into a datetime object.

        

        ```

        >>> date = date_format.parse("2017-06-03 15:32:00.2364-02:00")

        datetime.datetime(2017, 6, 3, 15, 32, 0, 236400, tzinfo=datetime.timezone(datetime.timedelta(-1, 79200)))

        ```

        

        ### `def format(self, date)`

        

        Format the passed in `datetime.datetime` object (`date`) as a string:

        

        ```

        >>> print(date_format.format(date))

        2017-06-03 15:32:00.2364-02:00

        ```

        

        ## Timezones

        

        If any part of the format provides a timezone, or UTC offset, then parsing 

        produces dates with a timezone indicating the relevant UTC offset.

        

        Likewise, if a dateformat has a timezone part, then dates passed to `.format()`

        must include a tzinfo value.

        

        If pytz is available, then some level of named timezone support is provided.

        

        ## Leading zeros

        

        All numeric parts of the date format are zero-padded to the number of characters

        in the spec.  I.e.  'DD' means that the day of the month is zero-padded to 2-digits.

        

        During parsing, a missing leading zero is usually ignored, but if there is no separator

        between parts (for example:  YYYYMMDD), then a missing leading zero will cause an error or bad value.

        

        Currently, all formatted dates are zero-padded, in the future, this may be controllable.

        

        ## Date format specification

        | Part | Example | Description |

        |---------|---------|---------------|

        | `+HHMM` | -0515 | A UTC offset provided as a 2-digit hour, and 2-digit minute, with no separator |

        | `+HH:MM` | -05:15 | A UTC offset provided as a 2-digit hour, and 2-digit minute, with a ':' separator |

        | `+HH` | -05 | A UTC offset provided as a 2-digit hour only |

        | `Dddddd` | Monday | The full locale-specific day of the week (Note, this value is ignored during date parsing, but added during date format) |

        | `Ddd` | Mon | The locale-specific short name for the day of the week (Ignored during parsing) |

        | `DD` | 05 | The zero-padded day of the month. |

        | `MMMMM` | September | Month as locale’s full name |

        | `MMM` | Sep | Month as locale’s abbreviated name |

        | `YYYY` | 2017 | Year with century as a number |

        | `YY` | 17 | Year without century as a zero-padded number |

        | `hh` | 09 | Hour as a zero-padded number |

        | `mm` | 06 | Minute as a zero-padded number |

        | `ss` | 45 | Second as a zero-padded number |

        | `SSSSSS` | 123456 | Microsecond as a zero-padded decimal number |

        | `SSSS`   | 1234 | 100-microseconds as a zero-padded number |

        | `SSS` | 123 | milliseconds as a zero-padded number |

        | `SS` | 12 | 10-milliseconds as a zero-padded number |

        | `am` `Am` `AM` `pm` `Pm` `PM` | am | either AM or PM depending on the hour.  `.format()` matches the case of the spec.  If present, the dateformat will default to 12-hour mode |

        | `of` | | Ignored during parsing, added during formtting |

        | `st` | th | The appropriate suffix for the day of the month, for example '1_st_ July', '2_nd_ March' |

        | `␣` | T | (Unicode OPEN BOX - U+2423) Matches either the character 'T' or a space ' '.  During formatting, 'T' is always used (this is provided to improve flexibility when parsing iso8601 formats) |

        | space | | Matches one or more spaces during parsing.  During formatting, one space will be output |

        | any of `:/-.,TZ()` | | Ignored during parsing, output as-is during formatting |

        

        

        # Examples

        

        | Format                   | Example                |

        |--------------------------|------------------------|

        | `YYYY-MM-DDThh:mm:ss`    | 2017-06-06T09:45:15    |

        | `YYYYMMDDhhmmss`         | 20170606094515         |

        | `YYYYMMDDhhmmss.SSSSSSZ` | 20170606094515.123456Z |

        | `MM/DD/YY hh:mm+HHMM`    | 06/06/17 09:45-0500    |

        

        

        # Library comparison

        

        ## dateformat ⇄ datetime (builtin python module)

        

        Dateformat is *not* trying to be a replacement for the builtin datetime module.  `datetime.datetime` objects are used as the input/output to the parsing and formatting methods.

        

        It is designed as a replacement for the  `datetime.datetime.strftime` and `datetime.datetime.strptime` methods, providing:

        

         * better timezone handling

         * a simpler/more common syntax for specifying the date formats

         * slightly faster parsing

        

        ## dateformat ⇄ dateutil.parser.parse()

        

        `dateutil.parser.parse`'s intent is to turn a string in an unknown format into a date.  It does that by using a variety of heuristics to try to figure out the format the date has been expressed in.

        

        This approach is highly useful, and very flexible, but suffers from a couple of drawbacks that dateformat doesn't have:

        

         * There is ambiguity about what date will be produced from a given string, there are situations where that risk cannot be accepted, and it's important for the system to only accept a certain date format

         * Because of all the work that dateutil is doing to work out the format used, it's fairly slow, at just under 10x slower than `strptime`, this is very noticable over 10s - 100s thousands of dates.

        

        ## dateformat ⇄ arrow

        

        arrow is the closest to the way dateformat works, the syntax for describing dates is very similar. Unfortunately, arrow constructs its parser every time a date is parsed, creating a significant overhead when parsing each date.

        

        ## dateformat ⇄ iso8601 / ciso8601

        

        ciso8601 is _really_ fast.  Unfortunately both these libraries only handle a single date format, so are not useful in this situation.

        

        # Benchmarks

        

        the `benchmark/` dir contains some simple scripts to show how the relative libraries perform at parsing and formatting dates.

        

        Running on a 2016 macbook pro, on Python 3.6.3 gave the following results (best of 3 runs):

        

        (Please note, the parse time chart y-axis has been clamped to 1s, but dateparser took 16s to complete)

        

        ![chart showing relative date parse performance](https://github.com/stestagg/dateformat/raw/master/benchmark/parse_times.png)

        

        ![chart showing relative date format performance](https://github.com/stestagg/dateformat/raw/master/benchmark/format_times.png)

        

        
Keywords: date time parsing formatting datetime
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Provides-Extra: test


%prep
%autosetup -n dateformat-0.9.7

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-dateformat -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Tue Apr 11 2023 Python_Bot <Python_Bot@openeuler.org> - 0.9.7-1
- Package Spec generated