[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]


    Search the Q&A Archives


I need a C++ program converting unix time (seconds from...

<< Back to: C++ FAQ (part 1 of 10)

Question by Sondergaard
Submitted on 11/26/2003
Related FAQ: C++ FAQ (part 1 of 10)
Rating: Rate this question: Vote
I need a C++ program converting unix time (seconds from January 1. 1970) to GMT or local time (Gothenburg). I am working in TestPoint (www.cec488.com). TP allows for calling routines in C++ programming.
Could anybody provide me with that utility in C++?
yours, Sondergaard
e-mail: soren.sondergaard@vgregion.se


Answer by priya
Submitted on 1/10/2006
Rating: Not yet rated Rate this answer: Vote
hi,
dis is 4 ya

#include<iostream.h>
#include<bios.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
#include<math.h>
#include<time.h>
#include<string.h>
#include<stdlib.h>

class point
{
public:
float x,y;
point(float m,float v)
{x=m+320;
y=v+260;
}
};

point conv(float rad,float ang)
{
float x,y,t,te,tem;
tem=ang-90;
te=tem-360;
float angr= 3.14/180*(te);
x=rad*cos(angr);
y=rad*sin(angr);
point temp(x,y);
return(temp);
}

class clock
{
float rad;
float minr,secr,horr;
public:
clock()
{rad=180;
minr=60;secr=80;horr=30;}
void drawc();
void draw();
}c;
void clock::draw()
{
char tem[12][2];char str[80];
int tot,net;
float mang,hang,sang,i,x;
float schg,mchg,hchg,sconv,mconv,hconv;
point c(0,0);
setcolor(4);
setlinestyle(0,0,2);
circle(c.x,c.y,rad-65);
setfillstyle(SOLID_FILL,11);
floodfill(c.x,c.y,4);
schg=6.0;
mchg=0.1;
hchg=0.0083;
tm *times=NULL;
time_t timer;
timer = time(NULL);
times = localtime(&timer);
sconv=times->tm_sec;
mconv=times->tm_min*60+times->tm_sec;
hconv=fabs(times->tm_hour%12)*60*60+times->tm_min*60+times->tm_sec;
sang=sconv*schg;
mang=mconv*mchg;
hang=hconv*hchg;
cprintf("Local time is: %s", asctime(times));
point min=conv(minr,mang),sec=conv(secr,sang),hor=conv(horr,hang);
point centre(0,0);
setlinestyle(0,0,3);
setcolor(0);
line(centre.x,centre.y,min.x,min.y);
setlinestyle(0,0,1);
setcolor(0);
line(centre.x,centre.y,sec.x,sec.y);
setlinestyle(0,0,3);
setcolor(0);
line(centre.x,centre.y,hor.x,hor.y);
delete times;
}
void clock::drawc()
{
char tem[12][2];
float radi=150,red=10,pi=3.14/6;
int tempx[]={0,0,0,0,-5,-5,-20,-25,-15};
int tempy[]={-5,-5,-5,-9,-12,-13,-10,-15,-23};
point centre(0,0);
setlinestyle(0,0,3);
setcolor(4);
settextstyle(4,HORIZ_DIR,5);
outtextxy(160,5,"ANALOG CLOCK");
outtextxy(160,25,"*********** ********");
setcolor(4);
circle(centre.x,centre.y,rad);
circle(centre.x,centre.y,rad+2);
setfillstyle(SOLID_FILL,3);
floodfill(centre.x,centre.y,4);
settextstyle(4,HORIZ_DIR,5);setcolor(0);
outtextxy(centre.x+radi*cos(pi*10)-red+10,centre.y+radi*sin(pi*10)-red-17,itoa(1,tem[0],10));
outtextxy(centre.x+radi*cos(pi*11)-red+10,centre.y+radi*sin(pi*11)-red-10,itoa(2,tem[1],10));
outtextxy(centre.x+radi*cos(pi*12)-red+10,centre.y+radi*sin(pi*12)-red-10,itoa(3,tem[2],10));
for(int k=1;k<=9;k++)
outtextxy(centre.x+radi*cos(pi*k)-red+tempx[k-1],centre.y+radi*sin(pi*k)-red+tempy[k-1],itoa(k+3,tem[2],10));
}
void tick()
{
int k;
for(int i=0;i<=5;i++)
{k=tan(i)*5000;
sound(k);delay(1);nosound();
}
}

void main()
{
int driver,mode;
driver=DETECT;
initgraph(&driver,&mode,"c:\\tc\\bgi");
cleardevice();
c.drawc();
c.draw();
while (bioskey(1) == 0)
{c.draw();tick();
sleep(1);}
getch();
}


here u go!
any doubts?
contact me:
venkhatapriya@yahoo.co.in

 

Your answer will be published for anyone to see and rate.  Your answer will not be displayed immediately.  If you'd like to get expert points and benefit from positive ratings, please create a new account or login into an existing account below.


Your name or nickname:
If you'd like to create a new account or access your existing account, put in your password here:
Your answer:

FAQS.ORG reserves the right to edit your answer as to improve its clarity.  By submitting your answer you authorize FAQS.ORG to publish your answer on the WWW without any restrictions. You agree to hold harmless and indemnify FAQS.ORG against any claims, costs, or damages resulting from publishing your answer.

 

FAQS.ORG makes no guarantees as to the accuracy of the posts. Each post is the personal opinion of the poster. These posts are not intended to substitute for medical, tax, legal, investment, accounting, or other professional advice. FAQS.ORG does not endorse any opinion or any product or service mentioned mentioned in these posts.

 

<< Back to: C++ FAQ (part 1 of 10)


[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]

© 2008 FAQS.ORG. All rights reserved.