473,399 Members | 3,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

convert a C++ CTime to a C# DateTime

Hello,

How can i convert a C++ CTime (4 bytes) into a C# DateTime ?
(my CTime is read in a file).

Thanks,
--
Chris
Nov 16 '05 #1
2 18792
dear Chris,

The Parse method of DateTime may handle this, take a try(remember to read
the CTime as a string first).

hope it helps.

"Chris" wrote:
Hello,

How can i convert a C++ CTime (4 bytes) into a C# DateTime ?
(my CTime is read in a file).

Thanks,
--
Chris

Nov 16 '05 #2

"Chris" <bo****@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hello,

How can i convert a C++ CTime (4 bytes) into a C# DateTime ?
(my CTime is read in a file).


I beleive that CTime has the same storage representation as time_t, which is
a 64 bit integer representing the number of seconds since January 1, 1970
UDT. Marshall it as an Int64, and do the date arithmetic yourself.

Something like
static DateTime CTimeToDate(Int64 CTime)
{
TimeSpan span = TimeSpan.FromTicks(CTime*TimeSpan.TicksPerSecond);
DateTime t = new DateTime(1970,1,1).Add(span);
return TimeZone.CurrentTimeZone.ToLocalTime(t);
}

David
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am...
3
by: Vicki Carlsen | last post by:
Hi, What is the easiest way to convert a DateTime object to a long?? - And the other way back?? (For database use) Regards, Vicki
2
by: Thomas Lindroos | last post by:
how to convert this??? string strDate = "19701105"; DateTime myDate = System.Convert.ToDateTime(strDate); ideas anyone /thomas lindroos
2
by: ad | last post by:
I use a textbox for user to enter a date. How can I determine if the string can convert to datetime.
0
by: Harry Haller | last post by:
The context is shown below in the getGames() method. I get errors on these lines: dtGames.Rows = (TimeSpan)dtGames.Rows; dtGames.Rows = (DayOfWeek)dtGames.Rows; because the playDate column...
5
by: Fabio | last post by:
Hi all! A simple question: I need to convert a DateTime var to a byte (or to a Int64). How? Thanks! --
2
by: santoshpayal | last post by:
Hi, I have a text file that contains a date column. The text file will be imported to database in SQL 2000 server. After to be importing, I want to convert the date column to date type. For...
7
by: groups | last post by:
This is my first foray into writing a generic method and maybe I've bitten off more than I can chew. My intent is to have a generic method that accepts a value name and that value will be...
3
by: AccessHunter | last post by:
Hi, I am trying to input data to a SQL server table from my source Access 2003 table. The table name is Cases. One of the columns 'DateClosed' has datetime as data type in the source database. In...
1
by: NareshN | last post by:
Hi All, I have stringarray called Timesplit with time like(17:00-2:00).How to store Timeplit array values into datetime array value.I am having 7 values that's why i am using TimeIn.I will...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.