Hello everyone,
I am working on a project when I have to convert a C# program into
Native C for speed purposes. I am using a .dll that creates a DateTime
object. Obviously, there is not DateTime object in Native C, but I
would like to know if there is a work-around to parse out the
day/month/year from this DateTime object. Any ideas? 6 6615
minboymike wrote: Hello everyone,
I am working on a project when I have to convert a C# program into Native C for speed purposes. I am using a .dll that creates a DateTime object. Obviously, there is not DateTime object in Native C, but I would like to know if there is a work-around to parse out the day/month/year from this DateTime object. Any ideas?
There's no such thing as "Native C". Do you mean ISO/ANSI Standard C?
If you want an answer to this, this group actually would be the right
place, had you went to the trouble of telling us what is a DateTime
object, so we can suggest C equivavalent.
If you specify what you need, there surely is a way of doing it in C.
--
BR, Vladimir
Hello,
The DateTime object i am speaking about is found under .NET.
Here is a link: http://msdn.microsoft.com/library/de...classtopic.asp
Basically, as I said before, I am writing a C program and want to parse
out the day/month/year from this DateTime object, but do not see any
means to do this in C. The time.h library uses time_t object/struct,
but when converting, there is a tyep-mismatch (obviously), causing the
time_t object i created to be set to deafult (1/1/1970).
minboymike wrote: Hello,
The DateTime object i am speaking about is found under .NET.
Here is a link: http://msdn.microsoft.com/library/de...classtopic.asp
Basically, as I said before, I am writing a C program and want to parse out the day/month/year from this DateTime object, but do not see any means to do this in C. The time.h library uses time_t object/struct, but when converting, there is a tyep-mismatch (obviously), causing the time_t object i created to be set to deafult (1/1/1970).
If you're looking to read the binary representation of this (i.e. you
are given a pointer to it), then you really need to know how .NET
stores it. Knowing that, you can construct a C `struct` that matches,
and read it out, or you could just walk through it byte by byte and
reconstruct the fields. This is going to be very non-portable, not
least for the possibility that the raw binary representation in .NET
may change.
You may be better off writing the fields of interest (maybe all) into a
text file, or some file of known, and well defined type, from your .NET
code, and read it out from your C code. For "file" you may substitute
memory buffer as well. NB, I'm suggesting that you design and document
the exchange format used, so it's under your control.
--
BR, Vladimir
Thanks for such a quick reply....
I understand the approach you are coming from, but unfortunately, had I
had the option to write those specific fields to a file, then read them
into my C program, than i wouldn't have the problem to begin with.
This problem of type mis-matching between .NET object DATETIME and C
seems to be causing the most problems for me. Thanks for giving me your
2 cents! Much appreciated.
minboymike wrote: Hello,
The DateTime object i am speaking about is found under .NET.
Here is a link: http://msdn.microsoft.com/library/de...classtopic.asp
Basically, as I said before, I am writing a C program and want to parse out the day/month/year from this DateTime object, but do not see any means to do this in C. The time.h library uses time_t object/struct, but when converting, there is a tyep-mismatch (obviously), causing the time_t object i created to be set to deafult (1/1/1970).
Get the DateTime.Ticks Property and use that to construct a time_t
object. Either pass the long, or an object that contains only this long.
Thanks for the reply!
I found a work around to my problem. The sample code provided with the
..dll I was implementing actually uses a COleDateTime object to store
the DateTime object I was looking at. Simply #include "ATLComTime .h"
did the trick! Thanks for everyone's help on this This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: usenet |
last post by:
I have inherited a table where date information was saved from PHP as a VARCHAR.
(Sigh.) This means that the so-called date fields look like this :
August 1, 2005, 9:09 am EDT
October 13, 2004, 12:28 pm EDT
This makes them essentially useless for sorting and logical evaluation.
Understandbly, the MySQL date functions don't seem able to convert the field to
a "real" date field. This yields a blank (or maybe null) "realdate" :
|
by: Carl |
last post by:
Hi, to be use with SQL server database
1- From window form textbox object
From this assignement,
txtTOTAL.Text="0.00m";
How do you convert back to decimal type ?
How do you assign a default datetime value to it ? How do
you convert back the text enter by user into datetime ?
|
by: Mika M |
last post by:
Is there better way to convert integer type date into DateTime type date
as doing like code below?
Dim intDate As Integer = 20051019
Dim dte As DateTime = New DateTime( _
CType(intDate.ToString.Substring(0, 4), Integer), _
CType(intDate.ToString.Substring(4, 2), Integer), _
CType(intDate.ToString.Substring(6, 2), Integer))
|
by: TofuTheGreat |
last post by:
I'm using "Now.ToOADate" for a record timestamp in a small database app
(it's what I want to do so don't try to disuade me ;-D).
Anyway. I store the value of Now.ToOADate in a string field in the
database (16 character field on a SQL server to be exact). Is there a
way of converting the text value from that field back into a readable
date/time?
For example if a date is stored in the 16 character field as the OLE
Automation format...
|
by: BenG |
last post by:
Hi. I have a gridview control on a web form (asp.net 2.0) that's bound to a
objectDataSource. The objectdatasource which is bound to a class I've
written in the DAL to read and update the database. The grid contains three
columns - an ID (GUID), a name (string) and a rowversion (timestamp), and
the data is passed to/from the page in an instance of a data entity object.
When I open the page the grid loads properly, but if I attempt to edit...
| |
by: Matt |
last post by:
Hi all,
So a lot of digging on doing this and still not a fabulous solution:
import time
# this takes the last_modified_date naive datetime, converts it to a
# UTC timetuple, converts that to a timestamp (seconds since the
# epoch), subtracts the timezone offset (in seconds), and then
converts
|
by: Brad Pears |
last post by:
I am using vb.net 2005 and SQL server 2000. In my table I have a date field
of type "smalldatetime". In my vb application, the user may or may not enter
a date value into the appropriate text box. I then want to pass the value of
this text box as a datetime variable to my stored procedure which inserts or
updates the row.
As I mentioned above, the textbox may be left blank - hence I would want to
pass a null to the stored proc. How do I...
|
by: Dirk Hagemann |
last post by:
Hello,
From a zone-file of a Microsoft Active Directory integrated DNS server
I get the date/time of the dynamic update entries in a format, which
is as far as I know the hours since january 1st 1901.
For Example: the number 3566839 is 27.11.07 7:00. To calculate this in
Excel I use this:
="01.01.1901"+(A1/24-(REST(A1;24)/24))+ZEIT(REST(A1;24);0;0) (put
3566839 in field A1 and switch the format of the result-field to the
corresponding...
|
by: Keith Hughitt |
last post by:
Hi,
I am having a little trouble figuring out how to convert a python
datetime to UTC. I have a UTC date (e.g. 2008-07-11 00:00:00). I would
like to create a UTC date so that when I send it to MySQL (which
treats all dates at local dates by default), it will already have
incorporated the proper UTC offset. I've tried looking through the
docs http://python.active-venture.com/lib/datetime-datetime.html), but
have not had any luck.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: 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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: 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...
| |