Re: Fractional Hours from datetime?

2010-01-12 Thread Ben Finney
W. eWatson wolftra...@invalid.com writes:

 See my post about the datetime controversy about 3-4 posts up from
 yours.

This forum is distributed, and there's no “up” or “3-4 messages” that is
common for all readers.

Could you give the Message-ID for that message?

-- 
 \ “As we enjoy great advantages from the inventions of others, we |
  `\  should be glad to serve others by any invention of ours; and |
_o__) this we should do freely and generously.” —Benjamin Franklin |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-12 Thread Steve Holden
Alf P. Steinbach wrote:
 * Steve Holden:
 Alf P. Steinbach wrote:
 * W. eWatson:
 Ben Finney wrote:
 W. eWatson wolftra...@invalid.com writes:

 See my post about the datetime controversy about 3-4 posts up from
 yours.
 This forum is distributed, and there's no “up” or “3-4 messages”
 that is
 common for all readers.

 Could you give the Message-ID for that message?

 Sort of like outer space I guess. No real direction. How would I find
 the message ID?
 In Thunderbird (the newsreader that you're using) there's a little '+'
 to the left of the message subject line.

 That shows the headers.

 It shows a very limited subset of the headers ...
 
 Really? My Thunderbird shows all headers. Perhaps you need to configure
 something.

I don't need to configure anything, thank you very much, it's already
configured perfectly nicely as it is, thank you, toView | Headers | Normal.

I agree I can switch to View | Headers | All, but for the typical modern
newsgroup post this reveals a bug in Thunderbird, because the headers
view isn't scrollable: not only can you not see all the headers, but
none of the message is visible either!

 Or do as I wrote next and you snipped, use [View - Message Source].
 
Yup, when I need to see that crap (which is almost never) I just hit
Ctrl/U and look at the headers in the message source.
 
 Cheers  hth. (even if rather off-topic by now, not even direct response!),
 
I've sucked a few eggs in my time. Thanks.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-12 Thread Martin P. Hellwig

W. eWatson wrote:
cut

  now = datetime.datetime.now()
  fractional_hour = now.hour + now.minute / 60.0


See my post about the datetime controversy about 3-4 posts up from yours.


If timezones might be a problem area, than it might be worth while to 
see it in the context of the actual application. For local, one user 
only, use, the problem will be practically non-existent. Multiple users 
across multiple machines will make it more difficult since you need a 
verified source for each users timezone. But then again what about 
travellers, wrongly set-up machines (right time wrong zone, wrong time 
right zone and wrong zone with wrong time?) or people who just prefer to 
do have their time set to UTC regardless of their location and season 
(when I travelled alot, I just set my wristwatch, phone and laptop to UTC).


--
MPH
http://blog.dcuktec.com
'If consumed, best digested with added seasoning to own preference.'
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-12 Thread W. eWatson

Ben Finney wrote:

Alf P. Steinbach al...@start.no writes:


And considering this, and the fact that Google's archive is now the
main Usenet archive, message id's are not that useful, really.


You've demonstrated only that Google is an unreliable Usenet archive.

One doesn't even need to use Usenet, in this case, since
comp.lang.python is a forum distributed both as a Usenet forum and a
mailing-list forum.


Good Clarke quote. (Not present here.)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-11 Thread M.-A. Lemburg
W. eWatson wrote:
 Maybe there's a more elegant way to do this. I want to express the
 result of datetime.datetime.now() in fractional hours.
 
 Here's one way.
 
 dt=datetime.datetime.now()
 xtup = dt.timetuple()
 h = xtup[3]+xtup[4]/60.0+xtup[5]/3600.00+xtup[6]/10**6
 #  now is in fractions of an hour

Here's how you'd do that with mxDateTime:

 from mx.DateTime import now
 now().abstime / 3600.0
13.17341068830755

.abstime gives you the time in fractional seconds.

http://www.egenix.com/products/python/mxBase/mxDateTime/

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jan 11 2010)
 Python/Zope Consulting and Support ...http://www.egenix.com/
 mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
 mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


::: Try our new mxODBC.Connect Python Database Interface for free ! 


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-11 Thread Martin P. Hellwig

W. eWatson wrote:
Maybe there's a more elegant way to do this. I want to express the 
result of datetime.datetime.now() in fractional hours.


Here's one way.

dt=datetime.datetime.now()
xtup = dt.timetuple()
h = xtup[3]+xtup[4]/60.0+xtup[5]/3600.00+xtup[6]/10**6
#  now is in fractions of an hour


Here is another (though personally I don't find this more elegant than 
yours, perhaps a bit more readable):


 now = datetime.datetime.now()
 fractional_hour = int(now.strftime('%H')) + int(now.strftime('%M')) 
/ 60.0


--
MPH
http://blog.dcuktec.com
'If consumed, best digested with added seasoning to own preference.'
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-11 Thread Martin P. Hellwig

Martin P. Hellwig wrote:

W. eWatson wrote:
Maybe there's a more elegant way to do this. I want to express the 
result of datetime.datetime.now() in fractional hours.


Here's one way.

dt=datetime.datetime.now()
xtup = dt.timetuple()
h = xtup[3]+xtup[4]/60.0+xtup[5]/3600.00+xtup[6]/10**6
#  now is in fractions of an hour


Here is another (though personally I don't find this more elegant than 
yours, perhaps a bit more readable):


  now = datetime.datetime.now()
  fractional_hour = int(now.strftime('%H')) + int(now.strftime('%M')) 
/ 60.0



Actually my version is overcomplicated:
 now = datetime.datetime.now()
 fractional_hour = now.hour + now.minute / 60.0

--
MPH
http://blog.dcuktec.com
'If consumed, best digested with added seasoning to own preference.'
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-11 Thread W. eWatson

Austyn wrote:

Here's an improvement in case you want your code to work outside of
Arizona:

from time import time, timezone
h = ((time() - timezone) / 3600) % 24

On Jan 10, 9:04 pm, Austyn aus...@gmail.com wrote:

How about:

import time
arizona_utc_offset = -7.00
h = (time.time() / 3600 + arizona_utc_offset) % 24

dt.timetuple()[6] is the day of the week; struct tm_time doesn't
include a sub-second field.

On Jan 10, 10:28 am, W. eWatson wolftra...@invalid.com wrote:




Maybe there's a more elegant way to do this. I want to express the
result of datetime.datetime.now() in fractional hours.
Here's one way.
dt=datetime.datetime.now()
xtup = dt.timetuple()
h = xtup[3]+xtup[4]/60.0+xtup[5]/3600.00+xtup[6]/10**6
#  now is in fractions of an hour


There seems to be some controversy about this and other matters of 
datetime. 
http://blog.twinapex.fi/2008/06/30/relativity-of-time-shortcomings-in-python-datetime-and-workaround/

--
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-11 Thread W. eWatson

Martin P. Hellwig wrote:

Martin P. Hellwig wrote:

W. eWatson wrote:
Maybe there's a more elegant way to do this. I want to express the 
result of datetime.datetime.now() in fractional hours.


Here's one way.

dt=datetime.datetime.now()
xtup = dt.timetuple()
h = xtup[3]+xtup[4]/60.0+xtup[5]/3600.00+xtup[6]/10**6
#  now is in fractions of an hour


Here is another (though personally I don't find this more elegant than 
yours, perhaps a bit more readable):


  now = datetime.datetime.now()
  fractional_hour = int(now.strftime('%H')) + 
int(now.strftime('%M')) / 60.0



Actually my version is overcomplicated:
  now = datetime.datetime.now()
  fractional_hour = now.hour + now.minute / 60.0


See my post about the datetime controversy about 3-4 posts up from yours.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-11 Thread W. eWatson

Martin P. Hellwig wrote:

Martin P. Hellwig wrote:

W. eWatson wrote:
Maybe there's a more elegant way to do this. I want to express the 
result of datetime.datetime.now() in fractional hours.


Here's one way.

dt=datetime.datetime.now()
xtup = dt.timetuple()
h = xtup[3]+xtup[4]/60.0+xtup[5]/3600.00+xtup[6]/10**6
#  now is in fractions of an hour


Here is another (though personally I don't find this more elegant than 
yours, perhaps a bit more readable):


  now = datetime.datetime.now()
  fractional_hour = int(now.strftime('%H')) + 
int(now.strftime('%M')) / 60.0



Actually my version is overcomplicated:
  now = datetime.datetime.now()
  fractional_hour = now.hour + now.minute / 60.0


See my post about the datetime controversy about 3-4 posts up from yours.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-11 Thread W. eWatson

Ben Finney wrote:

W. eWatson wolftra...@invalid.com writes:


See my post about the datetime controversy about 3-4 posts up from
yours.


This forum is distributed, and there's no “up” or “3-4 messages” that is
common for all readers.

Could you give the Message-ID for that message?

Sort of like outer space I guess. No real direction. How would I find 
the message ID?


It's easier to place the comment here:

There seems to be some controversy about this and other matters of 
datetime. 
http://blog.twinapex.fi/2008/06/30/relativity-of-time-shortcomings-in-python-datetime-and-workaround/

--
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-11 Thread Ben Finney
W. eWatson wolftra...@invalid.com writes:

 Ben Finney wrote:
  Could you give the Message-ID for that message?
 
 Sort of like outer space I guess. No real direction. How would I find
 the message ID?

It is a field in the header of every message. Show the full header, and
look for the field named ‘Message-ID’.

Ideally the value of that field is unique for all messages ever, but
there's no technical enforcement of that so it wouldn't serve to
*guarantee* unique identification. It's good enough to use as an
identifier in referring people to read messages, though.

-- 
 \ “Oh, I realize it's a penny here and a penny there, but look at |
  `\  me: I've worked myself up from nothing to a state of extreme |
_o__)  poverty.” —Groucho Marx |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-11 Thread Alf P. Steinbach

* W. eWatson:

Ben Finney wrote:

W. eWatson wolftra...@invalid.com writes:


See my post about the datetime controversy about 3-4 posts up from
yours.


This forum is distributed, and there's no “up” or “3-4 messages” that is
common for all readers.

Could you give the Message-ID for that message?

Sort of like outer space I guess. No real direction. How would I find 
the message ID?


In Thunderbird (the newsreader that you're using) there's a little '+' to the 
left of the message subject line.


That shows the headers.

You can alternatively use [View - Message Source], or keyboard [Ctrl U].

From that you find that the message id is

  hifkh3$br...@news.eternal-september.org

Then, kicking and cajoling your web browser to turn in the direction of Google 
Groups' Usenet archive,


  groups.google.com

you click the Advanced search button, paste the message id, and find that 
Google is unable to find your article, he he.


It's common, it's a very very unreliable archive.

However, as with most things, the Great Wall of Google prevents you from 
reporting this. There's no known way to report any bug to Google. As with 
Microsoft in the old days (reportedly Microsoft employees weren't even allowed 
to use the words bug or error with customers, only, at worst, problems), 
there are Google web forms and whatnot, but they all end up in cul-de-sacs, so 
that, together with the total impossibility of reaching any human at Google, one 
very very strongly suspects that it's Google *policy* to never admit to bugs, or 
waste time on fixing them. And so, I suspect, Google Earth still places Norway 
in the middle of Sweden, and I know for a fact that Google Groups still actively 
removes the space at the end of a valid signature delimiter, and Google Talk 
acts up in various ways, and so on: quite serious bugs, but no way to report 
them (thousands upon thousands have tried, at one time a movement was founded 
with its own web site, but the Great Wall of Google lets no-one through).


And considering this, and the fact that Google's archive is now the main Usenet 
archive, message id's are not that useful, really.


So asking for a Usenet article's message id is just showing off  --  that one is 
not up-to-date on current technology (it gets more unreliable year by year).




It's easier to place the comment here:

There seems to be some controversy about this and other matters of 
datetime. 
http://blog.twinapex.fi/2008/06/30/relativity-of-time-shortcomings-in-python-datetime-and-workaround/ 


No, not at all. :-)

Instead, just ignore silly requests for message id's.


Cheers  hth.,

- Alf
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-11 Thread Steve Holden
Alf P. Steinbach wrote:
 * W. eWatson:
 Ben Finney wrote:
 W. eWatson wolftra...@invalid.com writes:

 See my post about the datetime controversy about 3-4 posts up from
 yours.

 This forum is distributed, and there's no “up” or “3-4 messages” that is
 common for all readers.

 Could you give the Message-ID for that message?

 Sort of like outer space I guess. No real direction. How would I find
 the message ID?
 
 In Thunderbird (the newsreader that you're using) there's a little '+'
 to the left of the message subject line.
 
 That shows the headers.
 
It shows a very limited subset of the headers ...

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010  http://us.pycon.org/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-11 Thread Ben Finney
Alf P. Steinbach al...@start.no writes:

 And considering this, and the fact that Google's archive is now the
 main Usenet archive, message id's are not that useful, really.

You've demonstrated only that Google is an unreliable Usenet archive.

One doesn't even need to use Usenet, in this case, since
comp.lang.python is a forum distributed both as a Usenet forum and a
mailing-list forum.

-- 
 \   “Two possibilities exist: Either we are alone in the Universe |
  `\   or we are not. Both are equally terrifying.” —Arthur C. Clarke, |
_o__) 1999 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-11 Thread David Robinow
On Mon, Jan 11, 2010 at 10:26 PM, Ben Finney ben+pyt...@benfinney.id.au wrote:
 Alf P. Steinbach al...@start.no writes:

 And considering this, and the fact that Google's archive is now the
 main Usenet archive, message id's are not that useful, really.

 You've demonstrated only that Google is an unreliable Usenet archive.

 One doesn't even need to use Usenet, in this case, since
 comp.lang.python is a forum distributed both as a Usenet forum and a
 mailing-list forum.

 --
  \       “Two possibilities exist: Either we are alone in the Universe |
  `\   or we are not. Both are equally terrifying.” —Arthur C. Clarke, |
 _o__)                                                             1999 |
 Ben Finney
 --
 http://mail.python.org/mailman/listinfo/python-list

 The archive at http://mail.python.org/pipermail/python-list/  doesn't
show the message id either.
However, the monthly gzip'ed text file does have them.

FWIW, for you google-haters, I read python-list using gmail and I
don't see any message id's.
Great spam detection though.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-11 Thread Alf P. Steinbach

* Steve Holden:

Alf P. Steinbach wrote:

* W. eWatson:

Ben Finney wrote:

W. eWatson wolftra...@invalid.com writes:


See my post about the datetime controversy about 3-4 posts up from
yours.

This forum is distributed, and there's no “up” or “3-4 messages” that is
common for all readers.

Could you give the Message-ID for that message?


Sort of like outer space I guess. No real direction. How would I find
the message ID?

In Thunderbird (the newsreader that you're using) there's a little '+'
to the left of the message subject line.

That shows the headers.


It shows a very limited subset of the headers ...


Really? My Thunderbird shows all headers. Perhaps you need to configure 
something.

Or do as I wrote next and you snipped, use [View - Message Source].


Cheers  hth. (even if rather off-topic by now, not even direct response!),

- Alf
--
http://mail.python.org/mailman/listinfo/python-list


Fractional Hours from datetime?

2010-01-10 Thread W. eWatson
Maybe there's a more elegant way to do this. I want to express the 
result of datetime.datetime.now() in fractional hours.


Here's one way.

dt=datetime.datetime.now()
xtup = dt.timetuple()
h = xtup[3]+xtup[4]/60.0+xtup[5]/3600.00+xtup[6]/10**6
#  now is in fractions of an hour
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-10 Thread Austyn
How about:

import time
arizona_utc_offset = -7.00
h = (time.time() / 3600 + arizona_utc_offset) % 24

dt.timetuple()[6] is the day of the week; struct tm_time doesn't
include a sub-second field.

On Jan 10, 10:28 am, W. eWatson wolftra...@invalid.com wrote:
 Maybe there's a more elegant way to do this. I want to express the
 result of datetime.datetime.now() in fractional hours.

 Here's one way.

 dt=datetime.datetime.now()
 xtup = dt.timetuple()
 h = xtup[3]+xtup[4]/60.0+xtup[5]/3600.00+xtup[6]/10**6
 #  now is in fractions of an hour

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fractional Hours from datetime?

2010-01-10 Thread Austyn
Here's an improvement in case you want your code to work outside of
Arizona:

from time import time, timezone
h = ((time() - timezone) / 3600) % 24

On Jan 10, 9:04 pm, Austyn aus...@gmail.com wrote:
 How about:

 import time
 arizona_utc_offset = -7.00
 h = (time.time() / 3600 + arizona_utc_offset) % 24

 dt.timetuple()[6] is the day of the week; struct tm_time doesn't
 include a sub-second field.

 On Jan 10, 10:28 am, W. eWatson wolftra...@invalid.com wrote:



  Maybe there's a more elegant way to do this. I want to express the
  result of datetime.datetime.now() in fractional hours.

  Here's one way.

  dt=datetime.datetime.now()
  xtup = dt.timetuple()
  h = xtup[3]+xtup[4]/60.0+xtup[5]/3600.00+xtup[6]/10**6
  #  now is in fractions of an hour

-- 
http://mail.python.org/mailman/listinfo/python-list