How to extract information from command prompt, working with c++? - c++

i wanna make a program on c++ that tells you how many days, years and months need to pass to get to a certain date. Also i wanna include how many hours and minutes need to pass.
So my problem is that i do not know how to get the current date and time to a variable from the command "time" on cmd or anyway to get the current date date and time so it will work.
I accespt the program done already so i can see it and end my doubts.

http://www.cplusplus.com/reference/clibrary/ctime/

Get input with getline()
Parse string to date format
Use some time/data library to find the difference
Output to console

While this is almost certainly homework, you might find this post useful (points to the Boost library): C++ DateTime class

Related

how i can handle date in path

i want test api of my project.
i have Article model that have DateField that fill automatic and certainly each time save date.today()
so if i run this line of test code today it run correctly but future days will run incorrectly
response=self.client.get("/api/v1.0.0/blog/archive/en-2021-01/")
how i can change the date part of above line of code dynamically.I mean part "en-2021-01" of the above code .I also tested it with a variable but it did not work.like this
edate=str(date.today())
response=self.client.get("/api/v1.0.0/blog/archive/en-edate/")
i do not know how changed it to work
Thanks for trying to help me
hope you are using unittest...
for this purpose...
i think easiest solution during testing is use something like:
https://pypi.org/project/freezegun/
it mock your datetime and then your test run with specific date.. and always be success.
Just lead the example in the library.

C++ export into HTML with dates

I have probably simple problem for u. Hello.
I´ve written a function to count exact date of Easter in the year which someone will put in. So for example somebody puts in 2016 and he will get out sentence like "Easter will be 26.03.2016" .. If he will put in more years, like "2016, 2017, 2020 - 2024", he will get exact days of Easter in these years. But what I need to do is get these dates from C++ to HTML file dates.html .. Can somebody give me advice how to do it? Thanks very much.
Open the file (using for example ofstream), and write the html to that.
Show us some code and what you have already tried. Also take a look at this. It is a simply guide about if/ofstream and file-handling in C++.

Auto download file from FTP and check against existing file

I have an internal company need to create some sort of application which does the following daily at a specific time:
connects to our company's internal ftp url (not a secure url)
downloads a file with a specific file name
checks the newly downloaded file with the file downloaded the day before
throws an error if the file is the same or else displays a message saying all is good (or sends an email or something with that notification)
That's it. All i need to do is to check and make sure the file on the ftp is different from the day before.
Can anyone recommend an easy way of doing this? I've tried googling for a solution and not quite finding a straight answer.
I've been out of programming for the last 8 years but I still remember visual basic 6.0 and visual c++.
Please guide / suggest as you see fit.
Thank you :)
For vc++:
You could use any ftp client library for downloading a file. Take a look at this SO question which could be useful to you C++ FTP Library? . Then you need a proper way to chech the time. I think your program might need to run at statup and check for the system time at a specific interval if the time is due then download the file. For this you can take alook at this question How to get current time and date in C++? . Finally there are numerous ways for comparing the file and outputing the result, for starters is suggest you use the std.

Need to find the time of the last boot from a .cpp using linux ubuntu?

So I am very new to C++ and Linux and i need to find the time of the last boot from a c++ file. I have been using /proc files for the other info. I am not looking for up time.
I was trying to find a way to execute the "last reboot" command from my .cpp file but i cant figure this out. Is this possible, or is there a way to find the current time so i can subtract up time form the current?
Very lost...
This is homework by the way, but i have completed every other section and am just tied up on this one small part.
Also i have goggled for hours and just cant find a way... Am i misinterpreting something and its more simple then I am making it?
Just need the time of the last system boot
Thanks!
Get the current time using time (2) and subtract the number of seconds since boot that you get from sysinfo (2).
If you want the result in a nice, displayable format, use ctime (3) to turn it into a date/time string.
Figured it out with the /var/log/syslog not perfect since it will only work for 5 weeks but i think its sufficient for my assignment thanks all!

How do you open a file in C++ from HTTP where the URL is NOT the file location

I'm a first year comp sci student with a moderate knowledge of C++ and for a job I'm trying to put together a utility using a new U.S. Census Bureau API. It takes ID codes for things like state/county/census tract and the desired table and spits back out the desired table for the desired location.
Here's an example of a query for population stats for California and New York.
More examples can be found here: http://www.census.gov/developers/
My snag is that I've both never worked with files from HTTP and also I'm not sure how to handle a URL that outputs plain text but doesn't actually lead to the file location. Would it be possible to just use stdin? I don't understand how to handle the output given by one of the census query URLs.
Right now I'm using infile which I know isn't correct but I'm not sure a correct solution is either.
Thanks
The fact that the data you're receiving is (apparently) generated on the fly rather than coming from a file doesn't really make any difference to you -- you get the same stream of bytes either way.
My immediate advice would be to use cURL for the job. Most of your work is generating a correct URL, which is what cURL specializes in. It'll then make it pretty easy to grab the data. From there, you can use any of quite a few JSON parser libraries (e.g., yajl), or you can parse it on your own (JSON is simple enough to make that fairly practical). A quick Google indicates that a fair number of people have already done this, and have various blog posts and such giving information about how to do it (though I suspect most of that is probably unnecessary).