Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   time.gmtime (http://www.velocityreviews.com/forums/t587161-time-gmtime.html)

asit 01-25-2008 10:43 AM

time.gmtime
 
we know that time.gmtime(secs) takes a parameter secs. what does this
secs suggest ??What is it's significance ??

Harald Karner 01-25-2008 10:58 AM

Re: time.gmtime
 
asit wrote:
> we know that time.gmtime(secs) takes a parameter secs. what does this
> secs suggest ??What is it's significance ??


>>> import time
>>> help (time.gmtime)

Help on built-in function gmtime in module time:

gmtime(...)
gmtime([seconds]) -> (tm_year, tm_mon, tm_day, tm_hour, tm_min,
tm_sec, tm_wday, tm_yday, tm_isdst)

Convert seconds since the Epoch to a time tuple expressing UTC
(a.k.a. GMT). When 'seconds' is not passed in, convert the current time
instead.

>>> time.gmtime (0)

(1970, 1, 1, 0, 0, 0, 3, 1, 0)
>>>


Paul Boddie 01-25-2008 11:04 AM

Re: time.gmtime
 
On 25 Jan, 11:43, asit <lipu...@gmail.com> wrote:
> we know that time.gmtime(secs) takes a parameter secs. what does this
> secs suggest ??What is it's significance ??


From the documentation [1] with some editing:

"""
gmtime([secs])

Convert a time expressed in seconds since the epoch to a time
structure employing UTC. If secs is not provided or None, the current
time as returned by time.time() is used.

The epoch is the point where the time starts. On January 1st of that
year, at 0 hours, the ``time since the epoch'' is zero. For Unix, the
epoch is 1970. To find out what the epoch is, look at gmtime(0).
"""

So, the significance of the secs parameter is that it indicates a
specific point in time. Generally, you'll get this from functions like
time.time or from "UNIX timestamps" stored in things like files and
databases where people have wanted to indicate a point in time without
having to mention things like dates, times and timezones.

Paul

P.S. The datetime module is preferable to the time module, really. The
latter can drive you quite mad when things like timezones start to be
taken into account.

[1] http://docs.python.org/lib/module-time.html


All times are GMT. The time now is 04:33 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.