Questions tagged [python-arrow]

Arrow: Better dates & times for Python (https://arrow.readthedocs.io/en/latest/)

15 questions
6
votes
5 answers

Python Arrow milliseconds

I am trying to figure out one simple thing - how to convert arrow.Arrow object into milliseconds. I was reading following thread but it still not clear to me how to get a long number in milliseconds. I want something like: def get_millis(time:…
Wild Goat
  • 3,509
  • 12
  • 46
  • 87
2
votes
2 answers

Why is arrow.now() not in a range containing today's day?

I am testing the ability, in arrow, to check whether a date is in a range of dates: >>> arrow.get('06/09/2017', 'DD/MM/YYYY') in arrow.Arrow.range('day', arrow.get('06/09/2017', 'DD/MM/YYYY'), arrow.get('06/07/2018', 'DD/MM/YYYY')) True >>>…
WoJ
  • 27,165
  • 48
  • 180
  • 345
2
votes
1 answer

Python Arrow Not Formatting Date Properly

I am using the Python Arrow package for formatting a date that I've got. My input is: datetime=2017-10-01T00:10:00Z and timezone=US/Pacific My expected output is: Sun 10/01 @ 6:10pm I've tried a host of different date time conversions but I…
Peter Foti
  • 5,526
  • 6
  • 34
  • 47
1
vote
2 answers

How can I get the timezone from an Arrow date object

I need to retrieve the timezone from an Arrow date object Let's take this as an example: import arrow arrow_date = arrow.get("2000-01-01", tzinfo="America/Toronto") How can I return this tzinfo exactly as it is in the code above? I tried the…
Apollo-Roboto
  • 623
  • 5
  • 21
1
vote
1 answer

Python3 returning TypeError: expected string or bytes-like object

I'm working on a simple time zone finder using Python3 and the Arrow library. I was working on it yesterday, and it had been up and running perfectly. I boot up today, though, and I'm getting this error: TypeError: expected string or bytes-like…
Spencer
  • 23
  • 5
1
vote
2 answers

How to get the number of seconds between two dates with arrow?

I use arrow to handle dates and discovered that I do not know how to get natively the number of seconds between two dates: >>> import arrow >>> first = arrow.get('2019-03-06') >>> second = arrow.get('2019-02-06') >>> (first-second).days 28 >>>…
WoJ
  • 27,165
  • 48
  • 180
  • 345
0
votes
1 answer

Why does django-q throw exception with arrow time

I'm trying to create a Django-q schedule and following the documents to use arrow for the next run I get the following error with the schedule: schedule( func='test.tasks.test_task', name='test_task_nightly', …
Marco Fernandes
  • 326
  • 1
  • 4
  • 13
0
votes
1 answer

Conversion of timezone of datetime.time

I am writing Python code using arrow library to convert timezone (which will be UTC by default) in the string (without date) to another timezone. A sample string value is: 18:30+0000 The code snippet is : start = '18:30+0000' start_time =…
Saqib
  • 82
  • 7
0
votes
1 answer

Python Arrow timezone parsing

I'm trying to convert a string to DateTime object, The string: Saturday 8th of August 2020 07:48:11 AM CDT I'm using arrow package arrow.get('Saturday 8th of August 2020 09:23:34 AM CDT', 'dddd Mt[h] of MMMM YYYY HH:mm:ss A ZZZ') I'm getting the…
Alon Barad
  • 1,491
  • 1
  • 13
  • 26
0
votes
2 answers

How to use arrow's string parsing, and simultaneously set a timezone?

I would like, using arrow, to parse dates from strings. I do it via the documented way: >>> arrow.get('2013-05-05 12:30:45', 'YYYY-MM-DD HH:mm:ss') The string is parsed with the timezone +00:00. Is it possible to…
WoJ
  • 27,165
  • 48
  • 180
  • 345
0
votes
1 answer

python arrow shifting hours

I am trying to add (shift) 6 hours to an arrow object, but somehow it seems to replace it instead: >>> import arrow >>> print(arrow.utcnow(),arrow.utcnow().replace(hour=+6)) 2017-04-19T18:29:16.217239+00:00 2017-04-19T06:29:16.217304+00:00 The…
Sebastian
  • 5,471
  • 5
  • 35
  • 53
0
votes
1 answer

Arrow locale not working

arrow.get(datetime.now(), 'Asia/Shanghai').date() Returns datetime.date(2017, 3, 26) but it is 27th March there. How do I fix this?
user308827
  • 21,227
  • 87
  • 254
  • 417
0
votes
2 answers

Time zone for china not working in python arrow

arrow.get('2016-01-01') arrow.get(datetime.now(), 'US/Pacific') arrow.get(datetime.now(), 'China') arrow.get(datetime.now(), 'CT') arrow.get(datetime.now(), 'CST') So, the first two statements work, but the remaining 3 which are trying to convert…
user308827
  • 21,227
  • 87
  • 254
  • 417
0
votes
1 answer

Different date results from arrow library in python

(Pdb) arrow.get('2016-01-01') (Pdb) arrow.get('20160101') So, I want my function to be able to use arrow library in python to parse date strings. However, as can be seen from…
user308827
  • 21,227
  • 87
  • 254
  • 417
-1
votes
1 answer

How to check for a "between 23:00 and 6:30" condition?

I would like to check with arrow(*) whether the current time is between 23:00 and 6:30. I currently use naive checks in the code below but was wondering whether there is an arrow native construction available import arrow def check(now): if…
WoJ
  • 27,165
  • 48
  • 180
  • 345