ProgrammingThis 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.
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.
hi,all
Is there a function like get_day_of_week(), the input is a string like this:
"01-Aug-2005" and the return is the Number 1 to 7 stand for the Monday to Sunday, for example,
Code:
int rc;
rc = get_day_of_week("01-Aug-2005");
switch rc
case 1: printf("Monday!");break;
....
case 7: printf("Sunday!);break;
And the input date is not the current day,may be a day some years ago.
Now I want to konw is there a function in UNIX C, if not ,how can I write this function,,how can I convert the string to be a date !
I guess you'd need to parse the string. Looking through the manpages for the various unix time functions, I don't find anything for string-to-date conversion, though I could just be missing it.
you are right, I have looked up the linux c reference,and haven't seen any function for 'string-to-date', but some functions for 'date-to-string'.
The openVMS old operation system,and it has the system call "lib$day_of_week", I want to make the openVMS program run on the UNIX,So I think I must write this function myself. Do you know the openVMS is a open source system or not?
Originally posted by bigapple
Is there a function like get_day_of_week(), the input is a string like this:
"01-Aug-2005" and the return is the Number 1 to 7 stand for the Monday to Sunday,
Have a look at man 3 strptime. I think it's almost exactly what you need.
Thanks for Hko,
but I workstation is an AIX box,I have try 'man 3 strptime
',but it tells me the man page was not found or the strptime was not installed.
May be I will contact the Administrator of this box or try to find the source code of strptime.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.