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
6
votes
2 answers

Python dateutil date conversion

I'm trying to see if a list of dates are valid dates. I'm using the dateutil library, but I'm getting weird results. For example, when I try the following: import dateutil.parser as parser x = '10/84' date =…
ray smith
  • 380
  • 3
  • 14
6
votes
0 answers

error 3 on dateutil/zoneinfo using cx_freeze and pandas

When I try to compile the hello.py file with cx_freeze, I get the following error with pandas 0.15.2 but no error with 0.15.1. Has someone any idea on how to correct it ? I have include the dateutil/zoneinfo files with the include_files function but…
Alexis G
  • 1,259
  • 3
  • 14
  • 27
6
votes
1 answer

dateutil.parser.parse() and lost timezone information

I am trying to dateutil.parser.parse() to parse the default str(datetime.datetime.now()) output using timezone-aware datetimes. However, parse() seems to lose the timezone information and replace it with the local time timezone. Below is the IPython…
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
6
votes
2 answers

python dateutil unicode warning

im parsing some tweet's data from Twitter API using sixohsix library. Im trying to convert the date of the tweet to my locale: from pytz import timezone from dateutil import parser timestamp = parser.parse(tweet["created_at"]) timestamp_arg =…
Sebastian
  • 1,243
  • 1
  • 18
  • 34
6
votes
2 answers

Python dateutil parser, ignore non-date part of string

I am using dateutil to parse picture filenames and sort them according to date. Since not all my pictures have metadata, dateutil is trying to guess where to put them. Most of my pictures are in this…
deranjer
  • 309
  • 3
  • 17
6
votes
2 answers

Python Smart date parsing without a year specified

How can I parse dates (with dateutil) without a year so that when the current date is 17/11/2012 these dates will be parsed like this: print parser.parse("23 nov", dayfirst=True, yearfirst=False, fuzzy=True) # 23/11/2012 print parser.parse("28 dec",…
Dieter
  • 441
  • 1
  • 5
  • 15
6
votes
2 answers

Using python pandas to parse CSV with date in format Year, Day, Hour, Min, Sec

I have several CSV files with the format: Year,Day,Hour,Min,Sec.,P1'S1 2003, 1, 0, 0,12.22, 0.541 2003, 1, 1, 0,20.69, 0.708 2003, 1, 2, 0, 4.95, 0.520 2003, 1, 3, 0,13.42, 0.539 ... (where day, is the day of the year) and I'm trying to…
jbssm
  • 6,861
  • 13
  • 54
  • 81
5
votes
2 answers

dateutils rrule returns dates that 2 months apart

I am new to Python and also dateutil module. I am passing the following arguments: disclosure_start_date = resultsDict['fd_disclosure_start_date'] disclosure_end_date = datetime.datetime.now() disclosure_dates = [dt for dt in rrule(MONTHLY,…
DrBug
  • 2,004
  • 2
  • 20
  • 21
5
votes
11 answers

Get the last thursday of the current month using python

Following this answer I tried to get the date for last Thursday of the current month. But my code doesn't get out of loop. from datetime import datetime from dateutil.relativedelta import relativedelta, TH todayte = datetime.today() cmon =…
Frash
  • 724
  • 1
  • 10
  • 19
5
votes
1 answer

How can I set day to 1 when parsing incomplete date with dateutil.parser?

When I use dateutil.parser to parse an incomplete date that's missing the day, I get the day set to 10 for some reason: from dateutil.parser import parse >>> d1 = parse('2008 Apr 2') >>> d1 datetime.datetime(2008, 4, 2, 0, 0) >>> d2 = parse('2014…
I Z
  • 5,719
  • 19
  • 53
  • 100
5
votes
2 answers

Python - Getting the date format

I'm getting a date as a string, then I'm parsing it to datetime object. Is there any way to check what's is the date format of the object? Let's say that this is the object that I'm creating: modified_date =…
Alex Brodov
  • 3,365
  • 18
  • 43
  • 66
5
votes
2 answers

Python's datetime strptime() inconsistent between machines

I'm stumped. The date-cleaning functions I wrote work in Python 2.7.5 on my Mac but not in 2.7.6 on my Ubuntu server. Python 2.7.5 (default, Mar 9 2014, 22:15:05) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help",…
Nicole White
  • 7,720
  • 29
  • 31
5
votes
0 answers

Python's dateutil.tz.tzstr fails on string argument

With dateutil 2.2, I can't get the tzstr examples working (see below). It throws an error 'str' object has no attribute 'read'. Looking at the code, it fails on self.instream.read(1). What type should I be passing it? In [3]: import dateutil.tz In…
moinudin
  • 134,091
  • 45
  • 190
  • 216
5
votes
1 answer

Parsing human-readable recurring dates in Python

The problem. In my Django application, users create tasks for scheduled execution. The users are quite non-technical, and it would be great if they can write conventional human-readable expressions to define when to execute certain task, such…
Anatoly Scherbakov
  • 1,672
  • 1
  • 13
  • 20
5
votes
1 answer

Making the dateutil parser raise errors for ambiguous dates

dateutil.parser is used to parse a given string and convert it to a datetime.datetime object. It handles ambiguous dates, like "2-5-2013," by allowing dayfirst and yearfirst parameters to give precedent to a certain format. Is it possible to have…
tehsockz
  • 1,279
  • 1
  • 11
  • 24