[Gambas-user] Unix Date conversion

Laurent Carlier lordheavym at ...626...
Mon Jul 24 15:38:28 CEST 2006


Le lundi 24 juillet 2006 14:56, Benoit Minisini a écrit :
> On Monday 24 July 2006 14:48, Benoit Minisini wrote:
> > On Monday 24 July 2006 14:37, MrBiTs wrote:
> > > /*
> > >     That is correct. # of seconds since 1/1/1970.
> > > */
> > >
> > > Number of seconds since 1/1/1970 00:00:00 GMT.
> > >
> > > In perl, for example, we have a very simple line to convert Unix
> > > Timestamp into human-readable format:
> > >
> > > $ perl -e "print scalar localtime(0);"
> > > Wed Dec 31 21:00:00 1969
> > >
> > > As I told, this is GMT based. So, here in Brazil we  have GMT-3, then
> > > that's correct.
> > >
> > > CheerS
> >
> > I have read the man page...
> >
> > Actually this is *not* the true number of seconds before 1/1/1970,
> > because: - All years divisible by four are considered leap years.
> > - Sometimes a leap second is added to some years, and it is ignored.
> >
> > So maybe a dedicated function is needed...
>
> But according to:
>
> http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html
>
> The leap years are respected. The formula is:
>
> UnixDate =
> tm_sec + tm_min*60 + tm_hour*3600 + tm_yday*86400 +
>     (tm_year-70)*31536000 + ((tm_year-69)/4)*86400 -
>     ((tm_year-1)/100)*86400 + ((tm_year+299)/400)*86400
>
> So who is right? :-)
>
> I really should make a dedicated function!

I've made such function for fabien a long time ago, it was converting php 
(unix ?) date to gambas Date. It was for gambasforge.

If it isn't available anymore, i can do it again .....

Regards,
 




More information about the User mailing list