Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
02-05-2003, 10:24 AM
|
#1
|
LQ Newbie
Registered: Feb 2003
Posts: 17
Rep:
|
Time based applicatioon
Hello all,
First, I would like to say that I'm new to programming and thank you for the help in advance.
I'm currently trying to develop and application in C++ that should start and play a song, for example, every few hours. What I want to know how to make to the application check for time, and based on the value received from the system to start or not.
Pointing to the right direction is much appreciated.
Thanks
|
|
|
02-05-2003, 11:05 AM
|
#2
|
Member
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637
Rep:
|
You are looking for libraries like <sys/time.h>, but where you get the information I don't know. It would probably be better suited for a scripting langauge like bash.
|
|
|
02-05-2003, 11:11 AM
|
#3
|
Member
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637
Rep:
|
My computer gets time from a Time Server at the local University. In that case a langauge like Java probably makes getting that information a lot easier than C++. You can probably to use libraries like <sys/time.h> but those are definately platform specific and not part of standard C or standard C++. They are libraries of the OS.
|
|
|
02-05-2003, 11:31 AM
|
#4
|
Member
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637
Rep:
|
There is also a <time.h> header. I have to do stuff this afternood but I can maybe help later if nobody else does. If you just want to play music as certain times though and nothing else than for sure a shell script would be better.
|
|
|
02-05-2003, 11:43 AM
|
#5
|
Member
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637
Rep:
|
Is the application a daemon?
|
|
|
02-05-2003, 12:34 PM
|
#6
|
LQ Newbie
Registered: Feb 2003
Posts: 17
Original Poster
Rep:
|
Thanks GTKUser for your help,
Well, I don't want to use a script to do such task.
I just want the the application to keep checking for time at a certain intervals during the 24 hours span, and when the time set by the user is equal to the time is on the system, a reminder is displayed.
Thanks again
|
|
|
02-05-2003, 12:35 PM
|
#7
|
LQ Newbie
Registered: Feb 2003
Posts: 17
Original Poster
Rep:
|
It is going to be a KDE applet.
|
|
|
02-05-2003, 12:48 PM
|
#8
|
Member
Registered: Sep 2002
Location: Canada
Distribution: Redhat 9.0
Posts: 637
Rep:
|
Oh okay, so you are using QT and the program is a daemon. QT has specific libraries for dealing with system time. I have a book on QT with a chapter called Interfacing with the operating system. And one of the sections talks about working with date and time values.
Just reading the first few words:
Date and time values are inherently hard to make portable. Therefore, it's a good idea to use the classes provided by QT when you work with this kind of data.
Three QT classes are in this area: QDate, QTime, and QDateTime. ...
Look up those class prototypes.
|
|
|
All times are GMT -5. The time now is 11:54 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|