-4

In C# on Windows Vista - 7 with dot net 4.0 or less

I am trying to compare the values of login time, current time, and the modified time of a file to see which is the greater and which is least. I have found ways to declare and cast these three values but not as the same type. I figured unix epoch made the most since and I seem to be stuck with converting the long format of

File.GetLastWriteTime("time.cs" )

Apparently overflows are a problem, who would have guessed, not my esp. Such a superior os & language. Anyway. Can someone please give me a full example of how to cast return and output the modified time of a file to int32 unix epoch. Or, can some one show me, in full example how to compare the above three values without trolling a log file or the use of jQuery or defining functions or languages beyond the scope of what I have requested. Speed is key and the parameters are required not optional.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
nimrod
  • 1
  • or better yet since my end product is IL code is there any way into convincing the CLI that IL is actually assembly and do what is already built directly into your registers and kernel. discard and ignore. To just grab the upper byte of the most significant bit... of the string array. To be clear this is not me asking what it wrong... I know its wrong, I know why its wrong. How can I do it right. – nimrod Sep 19 '18 at 18:42
  • 1
    It is unclear what you are asking, all the values you mentioned are available as DateTime and can be compared as such. You can convert to unix time by substracting 1 jan 1970 utc, but if you cast that to int32 it will overflow somewhere in 2038. – stephanV Sep 19 '18 at 19:27

1 Answers1

-1

The csharp crowd doesn't have the answer? there is a surprise. Well this is about as exact as there being 365 days in a year but for my purpose it will work. Because two forms of builtin not traversal date time isn't enough. For the pleasure of all that is prime and dec ten. A solution:

DateTime dt = File.GetLastWriteTime("time.cs");

var sec = ( ( dt.Year - 1970 )*31536000) + (dt.Month*2592000) + (dt.Day*86400) + (dt.Hour*3600) + (dt.Minute*60) + (dt.Second * 1) - 2592000 - 86400;

I guess for windows this is actually considered efficient. Can anyone tell my why DateTime isn't just considered a string? is base24 replacing base 16 or some thing? Did we add a register to our processor just for msns inefficiencies. Im going with the ladder. Front end convenience is no excuse for back end ugliness. Ill be posting a pure assembly answer next on how to convert gregorian to epoch via means of base 2 and 127 bit addressing... crazy.

Poul Bak
  • 10,450
  • 5
  • 32
  • 57
nimrod
  • 1