Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Date selection by initial date

Date selection by initial date

Discuss PocketC for Palm OS (including Desktop Edition)

Postby Ralpf on Mon Mar 22, 2004 11:20 am

Since PocketC 6.5.1 you can open a date selection dialog. The initial date for this dialog has to be specified by secs which is the number of seconds since Jan 1, 1904 minus 2^31.
My question is how to change a given date to the secs format. I could`nt find a way for it.
Ralpf
 
Posts: 3
Joined: Fri Dec 29, 2000 7:32 pm

Postby Vigon on Mon Mar 22, 2004 10:43 pm

The answer may be here:
http://peter.verhas.com/tutorials/allexperts/298.html
but there is a little work to do...
Vigon
 
Posts: 43
Joined: Wed Apr 17, 2002 2:26 pm
Location: Venezuela

Postby Vigon on Tue Mar 23, 2004 2:26 am

Code: Select all
//DateToSeconds.pc
/*
Just an Idea:
Using a binary approximation,
begining in the year 1967 ,the middle of the range 1904-2031 (46751 days) (4039286400 secs) of the Palm OS.
and using the secs parameter of datex() as the approximation variable.
*/
int DateToSeconds(int Y, int M, int D){
   int i,targetdate,datefinder,offset;
   targetdate= Y*10000 + M*100 + D ;   //(year*10000+month*100+day)
   datefinder= 2019643200-2147483648;   // seconds (from 1904 to 1967 and 6 months) minus 2^31
   offset=2019643200;               //aprox. seconds in 63.5 years (Half range)(23192 days)
   for(i=0;i<32;i++){
      offset=offset/2;
      if(datex(datefinder,0)>targetdate)datefinder=datefinder-offset;
      else datefinder=datefinder+offset;
      }
   if(datex(datefinder,0)==targetdate)return datefinder;
   if(datex(datefinder,0)>targetdate)return (datefinder-86400);   //adjust
   if(datex(datefinder,0)<targetdate)return (datefinder+86400);   //adjust
}
main(){
selectdate(DateToSeconds(1999,12,31), 0, "DateToSeconds Working!"); //an example
}
Vigon
 
Posts: 43
Joined: Wed Apr 17, 2002 2:26 pm
Location: Venezuela

Postby dewey on Tue Mar 23, 2004 2:43 am

Thanks for providing code for this. In the next version, I will expose a function to do this directly.
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Postby Vilmos on Tue Jul 13, 2004 2:14 pm

Is it just me or does this sample always show you Jan 1, 1968? I tried random dates between today and 2010!

back to the drawing board I guess.

Vilmos
http://www.pocketdimension.com
Vilmos
 
Posts: 174
Joined: Tue Dec 05, 2000 6:13 pm
Location: Canada

Postby Vigon on Tue Jul 13, 2004 8:06 pm

Hi Vilmos, after your comments I tried several dates in the range and
the procedure was working OK.
I'll apreciate an example with the problem.

I used:

selectdate(DateToSeconds(2004,10,31), 0, "DateToSeconds Working!");
selectdate(DateToSeconds(2008,6,15), 0, "DateToSeconds Working!");
selectdate(DateToSeconds(2007,2,22), 0, "DateToSeconds Working!");
selectdate(DateToSeconds(2010,11,1), 0, "DateToSeconds Working!");

thanks,
Vigon
 
Posts: 43
Joined: Wed Apr 17, 2002 2:26 pm
Location: Venezuela

Postby Vilmos on Tue Jul 13, 2004 8:42 pm

The two dates I know for sure that I used are 2004/06/30 and today 2004/07/13.

I had just copied and pasted the post into a memo then compiled it on the palm. I had to put line breaks in but otherwise didn't modify anything on purpose but the dates.

I've solved my problem by using OnBoardC and the built-in Palm functions to resolve seconds to day. PocketC was slowing me down when I simply wanted a tiny calculator to show me what the max mileage can be for today on my car lease.

Vilmos
http://www.pocketdimension.com
Vilmos
 
Posts: 174
Joined: Tue Dec 05, 2000 6:13 pm
Location: Canada

Postby Vigon on Tue Jul 13, 2004 8:56 pm

I tried both and are working ok.
In the PocketC Desktop Editor with PalmOS Simulator on my PC and
in my handheld....

selectdate(DateToSeconds(2004,06,30), 0, "DateToSeconds Working!");
selectdate(DateToSeconds(2004,07,13), 0, "DateToSeconds Working!");

May be we're missing something!!
Vigon
 
Posts: 43
Joined: Wed Apr 17, 2002 2:26 pm
Location: Venezuela

Postby Vilmos on Tue Jul 13, 2004 9:29 pm

You are completely right. It works fine in PocketC Desktop. something happened when I pasted it into the Palm Desktop in a memo and then tried to compile it on the Palm.

I know the problem was that the memo was pasted as one long line which will not compile because there are comments within it. I'm sure that a comment ended up taking some code with it. You just can't tell on the Palm itself.

Ok I'll use that next time then. :)

Vilmos
http://www.pocketdimension.com
Vilmos
 
Posts: 174
Joined: Tue Dec 05, 2000 6:13 pm
Location: Canada


Return to PocketC for Palm OS

Who is online

Users browsing this forum: No registered users and 1 guest

cron