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
[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 - Calc Days between 2 Dates

Calc Days between 2 Dates

Discuss PocketC for CE (including Desktop Edition)

Postby CaseyLance on Wed Mar 13, 2002 11:59 am

Hello @ all

(sorry my english isn't sooo good <img src=icon_smile_wink.gif border=0 align=middle> )

I'm searching for a function / code that calculates the days between the given dates (in YYYYMMDD format). Could anyone help me ?

Thanks
CaseyLance
 
Posts: 3
Joined: Wed Mar 13, 2002 11:57 am

Postby guy on Wed Mar 13, 2002 12:52 pm

You can extract a function to do this from the code at:

http://www.cs.sunysb.edu/~algorith/implement/reingold/distrib/calendar.C

You won't need all of it. You'll also need to reimplement the algorithms in PocketC, but the info is there.


Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/pcktceapi.zip
Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby CaseyLance on Wed Mar 13, 2002 1:11 pm

Big thanks :)
CaseyLance
 
Posts: 3
Joined: Wed Mar 13, 2002 11:57 am

Postby guy on Wed Mar 13, 2002 1:45 pm

Extract of the code you need, converted into PocketC. The word <b>plus</b> in bold means a plus sign (the web board eats plus signs).

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
// Prototypes

DateDiff(string tFirst, string tSecond) ; // Subtract two dates
DateVal(string tYyyyMmDd) ; // Convert at date to an integer
LastDayOfMonth(int iMonth, int iYear) ; // Get number of days in a month


// Main program for testing

main() {

string tFirst ;
string tSecond ;

tFirst = gets("First date YYYYMMDD") ;
tSecond = gets("Second date YYYYMMDD") ;

confirm("Difference is " <b>plus</b> DateDiff(tFirst, tSecond) <b>plus</b> " days") ;

quit() ;
}

// Calculate the difference in days between two dates

DateDiff(string tFirst, string tSecond) {
return (DateVal(tSecond) - DateVal(tFirst)) ;
}

// Convert a date string into an integer date value

DateVal(string tYyyyMmDd) {

int iMonth ;
int iDay ;
int iYear ;
int iDaysSoFar ;
int iMonths ;

iDay = strmid(tYyyyMmDd, 6, 2) ;
iMonth = strmid(tYyyyMmDd, 4, 2) ;
iYear = strleft(tYyyyMmDd, 4) ;

iDaysSoFar = iDay ;

for (iMonths = iMonth - 1; iMonths > 0; iMonths--) { // days in prior months this year
iDaysSoFar = iDaysSoFar <b>plus</b> LastDayOfMonth(iMonths, iYear) ;
}

iDaysSoFar =
(iDaysSoFar // days this year
<b>plus</b> 365 * (iYear - 1) // days in previous years ignoring leap days
<b>plus</b> (iYear - 1)/4 // Julian leap days before this year...
- (iYear - 1)/100 // ...minus prior century years...
<b>plus</b> (iYear - 1)/400 // ...plus prior years divisible by 400
) ;

return (iDaysSoFar) ;
}

// Get the last day of the month (28, 29, 30 or 31)

LastDayOfMonth(int iMonth, int iYear) {

int iDay ;

switch (iMonth) {
case 2:
if ((((iYear % 4) == 0) && ((iYear % 100) != 0)) || ((iYear % 400) == 0)) {
iDay = 29 ;
} else {
iDay = 28 ;
}
break ;

case 4:
case 6:
case 9:
case 11:
iDay = 30 ;
break ;

default :
iDay = 31 ;
break ;
}

return (iDay) ;
}
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>


Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/pcktceapi.zip
Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby guy on Thu Mar 14, 2002 7:30 am

I've been worrying about the inefficiency of the code above. I basically converted parts of the original code without thinking about what it was doing. The method of working out how many days until the start of the current month is atrocious.

A better method would be to dispense with the LastDayOfMonth function completely and simply have an initialised 12 element global array containing the number of days from the beginning of the year until the start of each month (0, 31, 59, 90, 120, ...) for non leap years. Instead of calling the function in a loop counting down the months, just use the month as an index into the array to get the days so far. Then add one if it's a leap year and the month is after february.

This will save a loop containing a function call that contains a switch statement.



Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/pcktceapi.zip
Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby goodey on Fri Sep 13, 2002 4:29 pm

I think it would be easier and quicker to change DateVal() to this.

DateVal(string tYyyyMmDd){
int iDate[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
float fDate;

iDate[DAY] = strmid(tYyyyMmDd, 6, 2) ;
iDate[MONTH] = strmid(tYyyyMmDd, 4, 2) ;
iDate[YEAR] = strleft(tYyyyMmDd, 4) ;

udatetodate(iDate, fDate);
return fDate; //could be used as an int to for only getting the date part

}

Israel Vish
Israel Vish
goodey
 
Posts: 24
Joined: Wed Jan 17, 2001 10:34 pm
Location: USA

Postby KOU on Fri Sep 13, 2002 10:41 pm

There is already an library for calculating dates

you will need an lzh extractor:
http://www.sky.or.jp/~akihiro/software/awin.lzh

guy might want to have a look at this:
http://www.sky.or.jp/~akihiro/pocketc/develop.htm
select ASForm

These are Japanese sites, but this is not my site.
KOU
KOU
 
Posts: 92
Joined: Mon Mar 18, 2002 8:04 pm
Location: USA

Postby guy on Mon Sep 16, 2002 2:44 pm

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by KOU</i>
<br />
guy might want to have a look at this:
http://www.sky.or.jp/~akihiro/pocketc/develop.htm
select ASForm

<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

Interesting. It looks like a pirate copy of PCForm converted into Japanese with some extras added.

It feels like PCForm when you run it. It's possible that it is a reimplementation, however it uses the template file that I provide with PCForm. You'd have thought that they would at least have changed the variable names.

Time to reach for the lawyers.


Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby guy on Tue Sep 17, 2002 12:34 pm

Well what a surprise. The whole PocketC section of:

http://www.sky.or.jp/~akihiro

seems to have been deleted overnight. Fortunately I still have a copy of the distribution kit of AS Form, which contains the source file taken from the PCForm kit along with the .app file with the contact details of the "author". I also have copies of the web pages that were deleted.


If the author of AS Form is reading this, perhaps you'd like to contact me with an explanation before I decide whether to take this further.

So, Akihiro Sakai (akihiro@sky.or.jp), what about it?


Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby KOU on Tue Sep 17, 2002 5:18 pm

What a surprise!!!

I read in his homepage that he improved guy's PCForm and made ASForm but I didn't think that the author used modified SOURCE CODE of PCForm.

He was actually selling this software. about a $25.
So it actually has a timelimit for using it.

I think he thought anyone(Japanese) wouldn't notice.
PocketC and ofcourse PCForm is not really famous in Japanese WINCE community.

Japanese PocketC User's Group was actually recommending this.

He have other page written in Japanese. I will check it after I get an access to the Japanese Computer. (I am writing this from school)
KOU
 
Posts: 92
Joined: Mon Mar 18, 2002 8:04 pm
Location: USA

Postby KOU on Tue Sep 17, 2002 8:30 pm

What Akihiro Sakai said translated.

>>So, Akihiro Sakai (akihiro@sky.or.jp), what about it?
^- I guess that is the private address but...

He says you need this form to send mail to him.
http://www.sky.or.jp/~akihiro/pocketc/send.htm
username: guest
password: guest

http://www.sky.or.jp/~akihiro/

This is his other HP.
It looks like he develops Windows software too.

http://web.archive.org/web/200110210246 ... o/pocketc/
WWW archived his site.
I think he couldnt hide that.

Translated Desc. Page
[?¢‚Ǩ?ì?É
KOU
 
Posts: 92
Joined: Mon Mar 18, 2002 8:04 pm
Location: USA

Postby KOU on Wed Sep 18, 2002 1:37 am

More Translations...

Soft desc. in Vector (Japanese freeware/shareware download site. You can think it as a Japanese ver. of Download.com)
http://www.vector.co.jp/soft/other/wince/se180298.html

?¢‚Ǩ‚Äú{?Ü‚Äô\?Ü‚Äôt?Ü‚Äôg?Ü‚ÄôE?Ü‚ÄôF?Ü‚ÄôA?¢‚Ǩ?°?É
KOU
 
Posts: 92
Joined: Mon Mar 18, 2002 8:04 pm
Location: USA

Postby guy on Wed Sep 18, 2002 7:31 am

KOU - I didn't think you were Akihiro Sakai.

I contacted Vector yesterday. No reply yet.

I've had an email from Akihiro confirming that he is removing AS Form from the download sites.

AS Form includes the PCForm template file (with minor changes to the format of tags). I've asked Akihiro whether any other source components of PCForm were used.

I have absolutely no objection to people building software that does the same thing as PCForm (or does it better). It's just when they include parts of PCForm.

The way AS Form starts up, and the way it manages the screen are spookily the same as PCForm.

I will save a copy of this thread, but I don't think that you should delete your posts.




Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby guy on Wed Sep 18, 2002 12:10 pm

I have exchanged several emails with Akihiro Sakai and am now reasonably certain that only the template file was taken directly from PCForm.

I've therefore given him permission to use the template file providing it contains an acknowledgement of its origin.




Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum
guy
 
Posts: 879
Joined: Thu Dec 07, 2000 8:58 am
Location: United Kingdom

Postby KOU on Wed Sep 18, 2002 5:11 pm

Well OK then...
I will not delete my posts

KOU
KOU
 
Posts: 92
Joined: Mon Mar 18, 2002 8:04 pm
Location: USA


Return to PocketC for CE

Who is online

Users browsing this forum: No registered users and 3 guests

cron