What does os.time() return?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

What does os.time() return?

walsjs1
This is a pretty noob question, but what does os.time() return in Plua?
When I make a table with os.date('*t',os.time()) I get a year of 3106.
 Overall I am pretty confused.

Any help greatly appreciated.
Thanks,
Jim Walsh





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/plua/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply | Threaded
Open this post in threaded view
|

Re: What does os.time() return?

David McNab
walsjs1 wrote:
> This is a pretty noob question, but what does os.time() return in Plua?
> When I make a table with os.date('*t',os.time()) I get a year of 3106.

You might be getting ahead of yourself :)

>  Overall I am pretty confused.

Try doing:
  tostring(os.time())
and sticking the result into a field

Gotta be experimental.

Cheers
David



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/plua/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply | Threaded
Open this post in threaded view
|

Re: What does os.time() return?

walsjs1
--- In [hidden email], David McNab <david@...> wrote:
David,
Thanks for your reply.  I am working on an application that keeps
track of pregnant women, thier due dates and the number of weeks they
are currently along in their pregnancy.  Thus I need to do some date
arithmatic.

Taking your example print(tostring(os.time())) returns 3224383589.
This number appears to increase second by second, thus it assume it is
the number of seconds since some date.

If I print(tonumber(os.time())/(60*60*24*365)) I get 102.24.  I first
assumed that the result number was the number of seconds since
1/1/1900 which seems a reasonable choice.  But of course my result is
102 and this year is 2006.  I know my simple formula does not account
for leap years and such, but still that is 4 missing years!

So you see my confusion.
Appreciate any clarity you or anyone can share.
Thanks,
Jim

>
> walsjs1 wrote:
> > This is a pretty noob question, but what does os.time() return in
Plua?

> > When I make a table with os.date('*t',os.time()) I get a year of 3106.
>
> You might be getting ahead of yourself :)
>
> >  Overall I am pretty confused.
>
> Try doing:
>   tostring(os.time())
> and sticking the result into a field
>
> Gotta be experimental.
>
> Cheers
> David
>







 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/plua/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply | Threaded
Open this post in threaded view
|

Re: What does os.time() return?

walsjs1
OK I am a dope.  The os.time returns seconds since 1/1/1904.  This is
a palm convention.  

What threw me was that the os.date function also has an odd error (I
think).  os.date('*t',os.time()) returns a table as advertised.  but
the table.year field is equal to the actual year+1900.  Knowing this,
conversions seem easy.

date = os.time()
duedate = date + (60*60*24*7*40) -- 40 weeks of pregnancy
tbl = os.date('*t',duedate)
print(tbl.year-1900, tbl.month, tbl.day)

Take care,
Jim

--- In [hidden email], "walsjs1" <walsjs1@...> wrote:

>
> --- In [hidden email], David McNab <david@> wrote:
> David,
> Thanks for your reply.  I am working on an application that keeps
> track of pregnant women, thier due dates and the number of weeks they
> are currently along in their pregnancy.  Thus I need to do some date
> arithmatic.
>
> Taking your example print(tostring(os.time())) returns 3224383589.
> This number appears to increase second by second, thus it assume it is
> the number of seconds since some date.
>
> If I print(tonumber(os.time())/(60*60*24*365)) I get 102.24.  I first
> assumed that the result number was the number of seconds since
> 1/1/1900 which seems a reasonable choice.  But of course my result is
> 102 and this year is 2006.  I know my simple formula does not account
> for leap years and such, but still that is 4 missing years!
>
> So you see my confusion.
> Appreciate any clarity you or anyone can share.
> Thanks,
> Jim
>
> >
> > walsjs1 wrote:
> > > This is a pretty noob question, but what does os.time() return in
> Plua?
> > > When I make a table with os.date('*t',os.time()) I get a year of
3106.

> >
> > You might be getting ahead of yourself :)
> >
> > >  Overall I am pretty confused.
> >
> > Try doing:
> >   tostring(os.time())
> > and sticking the result into a field
> >
> > Gotta be experimental.
> >
> > Cheers
> > David
> >
>







 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/plua/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply | Threaded
Open this post in threaded view
|

Re: Re: What does os.time() return?

Javier Guerra Giraldez
On Sunday 05 March 2006 10:29 am, walsjs1 wrote:
>  OK I am a dope.  The os.time returns seconds since 1/1/1904.  This is
>  a palm convention. 

it seems to be inherited from macintosh (the original palm developers were
mac-headed?)  the original MacOS used 1904 as the base because that gave the
biggest time lapse where the simple rule "every year divisible by 4 is a leap
year" was actually true.  1900 wasn't leap, but 2000 was; and 2100 won't be.

>  What threw me was that the os.date function also has an odd error (I
>  think).  os.date('*t',os.time()) returns a table as advertised.  but
>  the table.year field is equal to the actual year+1900.  Knowing this,
>  conversions seem easy.

it does look like an ugly bug.

--
Javier


[Non-text portions of this message have been removed]



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/plua/

<*> To unsubscribe from this group, send an email to:
    [hidden email]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/