Sign in

username:

password:



Not a member?

Search rabbit-semi



Search tips

Subscribe to rabbit-semi



Ads

Discussion Groups

Discussion Groups | Rabbit-Semi | mktm() problems

This is a group for folks designing and programming embedded systems using the Rabbit Semiconductor C-programmable microcontroller. Rabbit Semi is a spin-off from Z-World who makes a variety of embedded modules and tools. This group is not affiliated with either Rabbit or Z-World, but is a user forum for sharing ideas, asking questions, flaunting knowledge, and other typical user group stuff. The Rabbit is a powerful uC, supported by a full-featured C-compiler.

mktm() problems - =?ISO-8859-2?Q?Guszt=E1v_Gy=F5ri?= - Aug 27 4:29:06 2008

Dear Everyone,

I just found an interesting issue using mktm(). What I'm trying to do is
that I have a tm struct, convert it into seconds since 01/01/1980 with
mktime(), subtract 86400 seconds from it (one day), then convert it back to
tm with mktm(). The restulting struct contains the correct time of the day,
but an absolutely wrong date, some 3 years earlier. The interesting thing is
that when I convert the resulting tm into seconds again, it is the correct
value, 86400 less than the original one. mktm() works fine in other spots of
my program. I use an RCM4200 with Dynamic C 10.09. Any ideas?

Thanks in advance, Gusztav



(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )


Re: mktm() problems - Tim S - Aug 27 9:25:09 2008

Gusztáv Győri wrote:

> Dear Everyone,
>
> I just found an interesting issue using mktm(). What I'm trying to do is
> that I have a tm struct, convert it into seconds since 01/01/1980 with
> mktime(), subtract 86400 seconds from it (one day), then convert it back to
> tm with mktm(). The restulting struct contains the correct time of the day,
> but an absolutely wrong date, some 3 years earlier. The interesting thing is
> that when I convert the resulting tm into seconds again, it is the correct
> value, 86400 less than the original one. mktm() works fine in other spots of
> my program. I use an RCM4200 with Dynamic C 10.09. Any ideas?
>
> Thanks in advance, Gusztav
>

Are you using long datatype; I think it has to be unsigned long type

so minus 86400UL

Tim S
------------------------------------



(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )

Re: Re: mktm() problems - =?ISO-8859-2?Q?Guszt=E1v_Gy=F5ri?= - Aug 27 9:56:15 2008

The values in seconds are correct, so this should be no problem.

Gusztav
>
> Are you using long datatype; I think it has to be unsigned long type
>
> so minus 86400UL
>
> Tim S



(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )

Re: Re: mktm() problems - Tim S - Aug 27 10:07:40 2008

Gusztáv Győri wrote:

> The values in seconds are correct, so this should be no problem.
>
> Gusztav

I take you are not using Dynamic C since you think it is not an problem.

Tim S
------------------------------------



(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )

Re: Re: Re: mktm() problems - =?ISO-8859-2?Q?Guszt=E1v_Gy=F5ri?= - Sep 1 7:22:12 2008

:) Nice one, I had to try it, but didn't help. Ideas are still welcome.



(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )

RE: Re: Re: mktm() problems - Julian Higginson - Sep 1 22:01:07 2008

Weird… I haven’t got all the parts of this discussion, but just fount them
on the groups page…

Oh well.

I can’t say I’ve ever had any problems with these functions.

…..so what happens if you don’t subtract the a day’s worth of seconds?

Does converting a tm struct to seconds, then back to a tm struct work?

Also, have you looked at the seconds value, and done the maths yourself to
check what you’re getting out of your tm struct when it’s converted?

Maybe you could include definitions and actual code segments??

Julian Higginson

Bruttour International P/L

http://www.bruttour.com.au

Ph: +612 9987 1581

From: r...@yahoogroups.com [mailto:r...@yahoogroups.com] On
Behalf Of Gusztáv Gyori
Sent: Monday, 1 September 2008 9:22 PM
To: r...@yahoogroups.com
Subject: Re: [rabbit-semi] Re: Re: mktm() problems

:) Nice one, I had to try it, but didn't help. Ideas are still welcome.



(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )