Hi :: I'm looking for a couple of code snippets, one that will retrieve :: Sun, :: :: Mon, Tue, Wed, Thu, Fri, Sat when given the day number and another :: that :: will retrieve Jan, Feb. . . . Dec when given the month number. Here is some code that might help it is a 'picarised' version of some code provided by Maxim for the 1Wire devices. There is by the way some Microchip code that does what you want if you download their Maestro utility. Anyhow feel play to free with this; sorry about the lack of comments, but it is a temporarily bit of abandoned code - but it does work. struct timecals { uint yr; uint mnth;uchar dy; uint hr; uint min; uchar scnd; }; timecals timecal; void period2secs(timecals *pTimeCal); void secs2period(timecals *pTimeDisp,ulong idata); ulong secs; const uint daysofar[]={0,0,31,59,90,120,151,181,212,243,273,304,334,365}; //Period conversion functions. Seconds to year/date/month/hours/mins/secs and in reverse //Day Date time period to seconds. *pTimeCal pointer to Time Fucntion void period2secs(timecals *pTimeCal) { uint temp,leap; //ulong secs; leap=0; if (timecal->yr > 30)// change to 18 years to avoid ulong conversion pTimeCal->yr=0; if (timecal->mnth > 2 ) { leap=(pTimeCal->yr &3)+1; } secs= 365*(pTimeCal->yr-2)+ ((pTimeCal->yr-1)/4)+ daysofar[timecal->mnth] + leap; secs+=pTimeCal->dy -1 ; secs=(86400 * secs) + timecal->scnd + (60 * timecal->min); temp=timecal->hr; secs+= 3600 * (ulong) temp; } // Seconds to time date conversion. 'idata' contains seconds info from iButton *pTimeCal pointer //To time structure. void secs2period(timecals *pTimeCal,ulong idata) { ulong temp; uchar leap; uint dy,m; //Max year 31 December 2030 23:59:59, if (idata> 0x3A468DFF) idata=0; temp=idata/60; pTimeCal->scnd=(idata-60*temp); idata=temp/60; pTimeCal->min=(temp-60*idata); temp=idata/24; pTimeCal->hr=(idata-24*temp); idata=4*(temp+731); pTimeCal->yr=(idata/1461); temp=((idata-(1461 * pTimeCal->yr))/4); m=13; do { m-=1; if (m > 2) { leap=(pTimeCal->yr &3)+1; } else { leap=0; } dy=daysofar[m]+leap; } while (temp < dy) pTimeCal->mnth=m; pTimeCal->dy=temp-dy+1; if (pTimeCal->dy==0) pTimeCal->dy=1; } -- cdb, colin@btech-online.co.uk on 24/06/2006 Web presence: www.btech-online.co.uk Hosted by: www.1and1.co.uk/?k_id=7988359 Do No Harm. We must never do evil that good may come of it: William Penn 1693 . -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.394 / Virus Database: 268.9.3/374 - Release Date: 6/23/2006 -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist