Hello!
I'm reading binary file exported from mainframe's tape. There used COBOL data types. Some date fields are represented by PIC '9999', but some - by FIXED(7). The first one I have recognized and converted quickly, but the second one is a problem.
I found the conversion algorithm (http://www.thescripts. com/forum/thread267116.ht ml) to convert FIXED(7) to UInt32 value, but now I don't know how to construct .Net DateTime from this UInt32.
Have somebody had deal with this problem? I tried distinct binary loayouts of date (http://webster.cs.ucr. edu/AoA/Windows/HTML/DataRepresentat iona7.html), but I didn't get result seeming correctly.
I tried to get UInt32 by two ways:
private static UInt32 IntFromFixed( Byte[] raw )
{
Int32 res = 0;
Byte b;
for( Int32 i = 0; i < raw.Length - 1; ++i )
{
res <<= 8;
b = raw[ i ];
res += ((b & 0xF) + (b >> 4)*10);
}
b = raw[ raw.Length - 1 ];
res <<= 8;
res += ((b >> 4)*10);
b &= 0xF;
if( b == 0xD )
res = -res;
return res;
}
OR
private static UInt32 IntFromFixed( Byte[] raw )
{
String res = "";
Byte b;
for( Int32 i = 0; i < raw.Length - 1; ++i )
{
b = raw[ i ];
res += ((b & 0xF) + (b >> 4)*10).ToString ();
}
b = raw[ raw.Length - 1 ];
res += ((b >> 4)*10).ToString ();
b &= 0xF;
if( b == 0xD )
res = "-" + res;
return UInt32.Parse( res );
}
And I tried to construct DateTime:
UInt32 dc = IntFromFixed( raw );
UInt32 y = (dc & 0x7F), m = (dc & 0xF000) >> 12, d = (dc & 0xF80) >> 7;
if( y == 0 )
return (DateTime?)null ;
return (DateTime?)new DateTime( 1900 + (int)y, (int)m, (int)d );
Thanks and good luck!
0 1129 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: sunny076 |
last post by:
Hi,
I am trying to convert from Julian to Gregorian data in C#. I was
exploring teh JulianCalendar and Gregorian calendar classes but still
not sure how I can do it. For example, the Julian date is 100033 and I
know that it is 2/2/2000 in Gregorian.
I would appreciate if anyone can help point me out.
|
by: - Steve - |
last post by:
I'm taking the value of the expire date out of an AD account (accountExpires
attribute) and passing it into this function.
static DateTime LargeIntToDateTime(ActiveDs.LargeInteger li)
{
long lTime;
lTime = (long)li.HighPart;
lTime <<= 32;
lTime |= (uint)li.LowPart;
return System.DateTime.FromFileTime(lTime);
|
by: Andrew Baker |
last post by:
this seems to be an SQL Server error but I cant work out how it is occuring.
Itr is also after 3am and I cant keep working but need to demo by tomorrow.
TIA. The code is:
Private Sub myMethod(ByVal cust As String, ByVal invDate As Date)
Dim paramDate As New OleDb.OleDbParameter, Dim paramCustomer As New
OleDb.OleDbParameter
paramDate.ParameterName = "@InvDate"
paramDate.Value = invDate
|
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: NateM |
last post by:
How do I convert any given date into a milliseconds value that
represents the number of milliseconds that have passed since January 1,
1970 00:00:00.000 GMT?
Is there an easy way to do this like Date in java?
Thanks,
Nate
| |
by: dm1608 |
last post by:
We have a number of COBOL programs, and some were currently developing, that
simply read TEXT based reports and scrap the reports for various
information.
I'm curious to know if anyone has attempted to do this sort of thing using
C#?
I would love to get rid of my COBOL programmer and especially the code, if I
can. Apparently, it is much simplier to edit/parse text reports in COBOL
than other languages.... so I'm being told.
|
by: Alok yadav |
last post by:
i am using a webservice in which a method is serach. i use this method
which accept a argument of date type in dd/MM/yyyy formate. i have a
textbox which accept the date from the user, when i convert textbox data
into Datatime formate it converted into MM/dd/yyyy formate, but i have a
requirement in dd/MM/yyyy formate.
please help me, i am using c#.
|
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: 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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: 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
| |