Hi,
I'm currently adding a new module to an old borland C3.1 application
(dos).
And I need to calculate a date by subtracting the number of days from
a given date.
I know I could use an array of days in the months and go back by
leaping when 1 is reached. (keeping the 29the of feb and january/year
in mind).
But is there no function in Borland C3.1 which will do this for me?
I couldn't find one in the help?
Regards
Laery 11 6478 th******@hotpop .com (Laery) wrote in
news:c6******** *************** ***@posting.goo gle.com: I'm currently adding a new module to an old borland C3.1 application (dos). And I need to calculate a date by subtracting the number of days from a given date.
[...]
I couldn't find one in the help?
Look-up difftime and localtime... They're functions that have been in the
Borland libraries at least since v1.5 and should help you do what you're
trying to do.
John
Laery wrote: Hi,
I'm currently adding a new module to an old borland C3.1 application (dos). And I need to calculate a date by subtracting the number of days from a given date.
Load the date into a struct tm, taking care to ensure that:
(a) all fields you don't set are cleared to 0, eg with:
struct tm date = (0); /* for now, just trust me on this */
(b) the year field contains the full year less 1900 (so, for 2005,
it would be set to 105).
(c) the month field is in the range 0 to 11.
(d) all other relevant fields are set correctly.
Now subtract the number of days you want, and then pass the
struct's address to mktime(), catching the result in a time_t
object.
If the result is not (time_t)-1 (which would indicate failure to
convert the date as you require), it can be passed to localtime()
or gmtime(), which both return pointers to struct tm from which
you can extract the date information you require.
John <oz***@ozbus.ne t.au> wrote: th******@hotpop .com (Laery) wrote in news:c6******** *************** ***@posting.goo gle.com:
I'm currently adding a new module to an old borland C3.1 application (dos). And I need to calculate a date by subtracting the number of days from a given date.
I couldn't find one in the help?
Look-up difftime and localtime... They're functions that have been in the Borland libraries at least since v1.5 and should help you do what you're trying to do.
No, they won't. difftime() gives the difference, in seconds, between two
time_t's; it doesn't allow you to change an existing time_t. localtime()
converts from time_t to struct tm, but doesn't do any other
computations.
Using mktime() is the right solution. If BC3.1 doesn't have it yet
(i.e., if it's pre-ISO), you _may_ be able to get away with subtracting
days*24*3600 from a time_t, but do note that this relies on time_t being
a straight number of seconds since the epoch, which it isn't required to
be. Doing so would make your code unportable, but if it's already
Borland-specific, that may not be a problem. Adding a comment explaining
the hack would be a good idea, even so.
Richard
Laery wrote: Hi,
I'm currently adding a new module to an old borland C3.1 application (dos). And I need to calculate a date by subtracting the number of days from a given date.
I know I could use an array of days in the months and go back by leaping when 1 is reached. (keeping the 29the of feb and january/year in mind). But is there no function in Borland C3.1 which will do this for me?
I couldn't find one in the help?
Regards Laery
I have a really robust date library which was published in the C User's
Journal a few years ago. Drop me a line and I will email it to you
(damn, I've got to get that web page up!). I also used it to write a
Unix shell utility called ADU (a date utility) that allows you to do
date math in the Unix shell. If there were a decent shell for Windows
you could use it there too.
In article <42************ ***@btinternet. com>, in******@btinte rnet.com says... Laery wrote: Hi,
I'm currently adding a new module to an old borland C3.1 application (dos). And I need to calculate a date by subtracting the number of days from a given date.
Load the date into a struct tm, taking care to ensure that:
(a) all fields you don't set are cleared to 0, eg with: struct tm date = (0); /* for now, just trust me on this */
It would be more trustworthy with braces instead of parens. :-)
--
Randy Howard (2reply remove FOOBAR)
"Making it hard to do stupid things often makes it hard
to do smart ones too." -- Andrew Koenig
Jack Klein wrote: On Thu, 24 Feb 2005 11:04:15 +0000 (UTC), infobahn <in******@btint ernet.com> wrote in comp.lang.c:
(a) all fields you don't set are cleared to 0, eg with: struct tm date = (0); /* for now, just trust me on this */
ITYM struct tm date = { 0 };
I do indeed. I was clearly tempting fate a little too much with that
comment.
Randy Howard wrote: In article <42************ ***@btinternet. com>, in******@btinte rnet.com says... Laery wrote: Hi,
I'm currently adding a new module to an old borland C3.1 application (dos). And I need to calculate a date by subtracting the number of days from a given date.
Load the date into a struct tm, taking care to ensure that:
(a) all fields you don't set are cleared to 0, eg with: struct tm date = (0); /* for now, just trust me on this */
It would be more trustworthy with braces instead of parens. :-)
<sigh>
Some days, it just doesn't pay to fire up your newsreader. :-$
</sigh>
Hello Stan
If you could mail me a copy of the date library you are talking about,
that will be very kind of you. Just mail it to me at
ptiwaryATmahind rabtDOTcom
Thanks in advance. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: JP SIngh |
last post by:
Hi All
I need to calculate the number of working days between the two dates entered
on an ASP page. I am not that great a coder in ASP and was wondering if
someone can help.
Basically the form has Two textboxes to enter dates
From Date - Fdate
To Date - TDate
|
by: Steve |
last post by:
Hi all
How would I find out the average date when given a bunch of dates? For
example, I want to find the average length in time from the following dates:
----------------------------------------------------
Start Date End Date
01/01/2004 12:50pm 02/01/2004 18:40pm
02/01/2004 13:40pm 02/01/2004 13:57pm
02/01/2004 14:30pm 02/01/2004 19:50pm
|
by: Frank |
last post by:
For my website i would like to display the age of my son in years,
months, days and hours.
For now i manage to get a result for totals. Like the total number of
days.
This is the beginning:
starttime = Date.parse("Aug 10,2003, 07:07")
sdt = new Date(starttime)
|
by: dlx_son |
last post by:
Here is the code so far
<form name="thisform">
<h3>Enter time to add to or subtract from:</h3>
(If not entered, current time will be used)<br>
Day: <input name="d1" alt="Day of month" size=3>
Month: <input name="m1" alt="Month" size=3>
Year: <input name="y1" alt="Year" size=5> (4 digits for year, e.g.
|
by: charliewest |
last post by:
Can someone pls point me to or recommend the easiest way to calculate
someone´s age using the TimeSpan object, in .NET CF?
Isn´t there a simple way to use the TimeSpan object to calculate the elapsed
time and somehow convert the days to years w/out using the VB DLL?
Thanks.
| |
by: rohayre |
last post by:
Im a long time java developer and actually have never done anything
with java scripting. I'd like to write a short simple script for
calculating a date in the future based on today's date and a letter.
Can I use javascripting to create a webpage to allow a user to enter a
letter and then click a button to find a future calendar date? I'm just
not sure how much user interaction scripting allows. Does java
scripting allow buttons, textfields...
|
by: Beemer Biker |
last post by:
I cant seem to get that date into any DateTime to make my calculation
directly by subtracting "01-01-0000" from "now".
After reading this:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=11469&objectType=File
I kluged up this routine that works:
// convert date time into that funny matlab serial date time that starts at
jan 1, 0000
private string DT2Matlab(DateTime thisDT)
|
by: shmoopie |
last post by:
Hi,
I have a php form that I want to use to pass a user specified "start date" and "end date" to a mysql database to retrieve reservations.
I want the number of days up to and including the "end date" to be displayed for both of these scenarios:
1) The item is still on loan as of the "end date"
2) The item has already been returned as of the "end date"
Right now I have it working by specifying a "start date", but the "end date" is...
|
by: FishVal |
last post by:
IMHO, the following is not a how-to-do instruction to solve a particular problem but more a concept-proof stuff demonstrating possibilities of SQL.
So, let us say the problem is to calculate business days count which is defined as count of days (optionally inclusive in the current implementation) excluding weekend days and holidays.
Let us say periods to calculate are stored in table associated with contacts.
keyPeriodID -...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |