Questions tagged [python-dateutil]

The dateutil module provides powerful extensions to the standard datetime module, available as an extension module which is compatible with Python 2.3+.

The dateutil module provides powerful extensions to the standard datetime module, available as a Python extension module which works with Python 2.3+.

432 questions
18
votes
1 answer

dateutil and pytz give different results

I have an issue comparing outputs with dateutil and pytz. I'm creating a aware datetime object (UTC) and then converting to a given time zone, but I get different answers. I suspect that dateutil sometimes gives wrong results because it has problems…
r_31415
  • 8,752
  • 17
  • 74
  • 121
17
votes
4 answers

Parsing a date in python without using a default

I'm using python's dateutil.parser tool to parse some dates I'm getting from a third party feed. It allows specifying a default date, which itself defaults to today, for filling in missing elements of the parsed date. While this is in general…
Mark Tozzi
  • 10,353
  • 5
  • 22
  • 30
15
votes
4 answers

How to use dateutil.relativedelta in Python 3.x?

Hello I am trying to use relativedelta from the dateutil module. I want to do what is mentioned here, add some months to a given datetime object. But I'm trying to use Python 3 for this and I am getting the following error: Traceback (most recent…
aairey
  • 310
  • 1
  • 3
  • 13
15
votes
3 answers

dateutil.relativedelta - How to get duration in days?

I wish to get the total duration of a relativedelta in terms of days. Expected: dateutil.timedelta(1 month, 24 days) -> dateutil.timedelta(55 days) What I tried: dateutil.timedelta(1 month, 24 days).days -> 24 (WRONG) Is there a simple way to do…
user2422457
14
votes
4 answers

Import Error: "No module named 'dateutil' "

I installed Python-Dateutil package, but when i import it in my script , it's throwing error: import dateutil ImportError: No module named 'dateutil' when i checked the lib folder, dateutil.eggs files are there , because of this i can not run…
Abhinaba
  • 161
  • 1
  • 2
  • 6
14
votes
2 answers

Python newbie - PIP / invalid syntax error

Ok, totally newbie to programming and python. Running Windows 7, python 2.7 x64. I am trying in install dateutil package using pip. I installed pip, numpy and pandas... which were pretty straightforward as they are exe files. I am now trying to use…
user2338676
  • 141
  • 1
  • 1
  • 3
14
votes
3 answers

How to handle DST and TZ in recurring events?

Does dateutil rrule support DST and TZ? Need something similar to iCalendar RRULE. If not - how to tackle this problem (scheduling recurring events & DST offset change) Imports >>> from django.utils import timezone >>> import pytz >>> from datetime…
g00fy
  • 4,717
  • 1
  • 30
  • 46
13
votes
3 answers

Inferring date format versus passing a parser

Pandas internals question: I've been surprised to find a few times that explicitly passing a callable to date_parser within pandas.read_csv results in much slower read time than simply using infer_datetime_format=True. Why is this? Will timing…
Brad Solomon
  • 38,521
  • 31
  • 149
  • 235
12
votes
3 answers

How to install the Six module in Python2.7

I am using Python 2.7 and trying to use dateutil as follows: from dateutil import parser as _date_parser However, I get the following error: Traceback (most recent call last): File "", line 1, in from dateutil import…
Ravi
  • 3,223
  • 7
  • 37
  • 49
12
votes
5 answers

Using dateutil.parser to parse a date in another language

Dateutil is a great tool for parsing dates in string format. for example from dateutil.parser import parse parse("Tue, 01 Oct 2013 14:26:00 -0300") returns datetime.datetime(2013, 10, 1, 14, 26, tzinfo=tzoffset(None, -10800)) however, parse("Ter,…
fccoelho
  • 6,012
  • 10
  • 55
  • 67
12
votes
1 answer

Trouble in parsing date using dateutil

I am using python-dateutil for parsing a date from a string: import dateutil.parser print dateutil.parser.parse('some null string', fuzzy=True).date() 2012-10-18 print dateutil.parser.parse('some 31 Oct 2012 string',…
akhter wahab
  • 4,045
  • 1
  • 25
  • 47
11
votes
2 answers

Is this the right way to set a timezone with dateutil?

>>> import dateutil.parser, dateutil.tz as tz >>> dateutil.parser.parse('2017-08-09 10:45 am').replace(tzinfo=tz.gettz('America/New_York')) datetime.datetime(2017, 8, 9, 10, 45, tzinfo=tzfile('/usr/share/zoneinfo/America/New_York')) Is that really…
Wayne Werner
  • 49,299
  • 29
  • 200
  • 290
11
votes
3 answers

How to convert a timedelta to a string and back again

Dateutil's timedelta object appears to have a custom __str__ method: In [1]: from datetime import timedelta In [2]: td = timedelta(hours=2) In [3]: str(td) Out[3]: '2:00:00' What I'd like to do is re-create a timedelta object from its string…
Kurt Peek
  • 52,165
  • 91
  • 301
  • 526
11
votes
4 answers

Add one month to a given date (rounded day after) with Python

I'd like to add one month to a given date import datetime dt = datetime.datetime(year=2014, month=5, day=2) so I should get datetime.datetime(year=2014, month=6, day=2) but with dt = datetime.datetime(year=2015, month=1, day=31) I should…
scls
  • 16,591
  • 10
  • 44
  • 55
11
votes
4 answers

Elegant way to convert python datetime.timedelta to dateutil.relativedelta

Is there an elegant was to convert between relativedelta and timedelta? The use case is getting user input ISO date. Python's isodate will return either isodate.duration.Duration or datetime.timedelta. We need the features of relativedelta (per What…
Williams
  • 4,044
  • 1
  • 37
  • 53
1
2
3
28 29