Click here to Skip to main content
15,887,895 members
Home / Discussions / C#
   

C#

 
AnswerRe: Issues in Connecting to SQL Server Database (on other machine) with C# windows Application Pin
John D. Sanders4-Feb-14 9:11
John D. Sanders4-Feb-14 9:11 
QuestionExecution of query?? Pin
Member 105648504-Feb-14 0:42
Member 105648504-Feb-14 0:42 
AnswerRe: Execution of query?? Pin
BBatts4-Feb-14 1:40
BBatts4-Feb-14 1:40 
AnswerRe: Execution of query?? Pin
Richard Deeming4-Feb-14 2:54
mveRichard Deeming4-Feb-14 2:54 
GeneralRe: Execution of query?? Pin
Dave Kreskowiak4-Feb-14 4:25
mveDave Kreskowiak4-Feb-14 4:25 
AnswerRe: Execution of query?? Pin
Eddy Vluggen4-Feb-14 2:59
professionalEddy Vluggen4-Feb-14 2:59 
SuggestionRe: Execution of query?? Pin
thatraja4-Feb-14 3:19
professionalthatraja4-Feb-14 3:19 
AnswerRe: Execution of query?? Pin
Dave Kreskowiak4-Feb-14 4:26
mveDave Kreskowiak4-Feb-14 4:26 
AnswerRe: Execution of query?? Pin
Marco Bertschi5-Feb-14 0:16
protectorMarco Bertschi5-Feb-14 0:16 
Questionconvert MySQL UTC_TIMESTAMP() to user local time Pin
Jassim Rahma4-Feb-14 0:13
Jassim Rahma4-Feb-14 0:13 
AnswerRe: convert MySQL UTC_TIMESTAMP() to user local time Pin
Dave Kreskowiak4-Feb-14 4:21
mveDave Kreskowiak4-Feb-14 4:21 
QuestionSense of making my own Timestamp class? Pin
Marco Bertschi3-Feb-14 20:42
protectorMarco Bertschi3-Feb-14 20:42 
AnswerRe: Sense of making my own Timestamp class? Pin
V.3-Feb-14 21:26
professionalV.3-Feb-14 21:26 
GeneralRe: Sense of making my own Timestamp class? Pin
Marco Bertschi3-Feb-14 21:35
protectorMarco Bertschi3-Feb-14 21:35 
GeneralRe: Sense of making my own Timestamp class? Pin
BillWoodruff4-Feb-14 12:43
professionalBillWoodruff4-Feb-14 12:43 
GeneralRe: Sense of making my own Timestamp class? Pin
Dave Kreskowiak4-Feb-14 13:42
mveDave Kreskowiak4-Feb-14 13:42 
AnswerRe: Sense of making my own Timestamp class? Pin
BillWoodruff4-Feb-14 3:56
professionalBillWoodruff4-Feb-14 3:56 
Marco Bertschi wrote:
Can I achieve the same with System.DateTime?
Based on the observation that all of your Properties, except milliseconds, are 'get only, I would say "yes," if you were willing to accept the limitations of inheriting from a data-structure like a Tuple<T1,T2,T3> ... given the fact that Tuple instances are immutable.

I don't claim to have thought through your use scenario here in any great depth, or to fully understand your goals here, but here's a quick sketch:
C#
using System;

namespace Feb4_2014_InheritFromTupleT1T2T3
{
    public class DateTimeEx: Tuple<DateTime, long, Int32>
    {
        private const string msPrefix = ":Z";
        private const string tzPlus = "+";

        private string tzPre;

        public DateTime dateTime { set; get; }

        public long milliSeconds { set; get; }

        public Int32 utcOffset { set; get; }

        public DateTimeEx(DateTime datetime, long millisec, Int32 utcoff) : base(datetime, millisec, utcoff)
        {
            dateTime = datetime;
            milliSeconds = millisec;
            utcOffset = utcoff;
        }

        public override string ToString()
        {
            tzPre = (milliSeconds < 0) ? "" : tzPlus;

            return string.Format("{0}-{1}-{2}T{3}:{4}:{5}.{6}Z{7}{8}", Item1.Year, Item1.Month, Item1.Day, Item1.Hour, Item1.Minute, Item1.Second, milliSeconds, tzPre, utcOffset);
        }
    }
}
Here's the results of a simple test:
DateTime rightNow = DateTime.Now;

DateTimeEx dEx1 = new DateTimeEx(rightNow, 0, 7);
DateTimeEx dEx2 = new DateTimeEx(rightNow, 0, 7);
DateTimeEx dEx3 = new DateTimeEx(rightNow, 230, 4);

Console.WriteLine(dEx1); // => 2014-2-4T21:35:19.0Z+7
Console.WriteLine(dEx3); // => 2014-2-4T21:38:1.230Z+4

Console.WriteLine(dEx1.Equals(dEx2)); // => true
Console.WriteLine(dEx1.Equals(dEx3)); // => false
I would hope what you would get from this is being able to use Parse, and ParseExact on the DateTime component, and, hopefully, save you from writing some of the overloads. But, whether you could use in the context of whatever your doing with SysLog: I ain't got a clue.

Hope this is helpful.
“But I don't want to go among mad people,” Alice remarked.

“Oh, you can't help that,” said the Cat: “we're all mad here. I'm mad. You're mad.”

“How do you know I'm mad?” said Alice.

“You must be," said the Cat, or you wouldn't have come here.” Lewis Carroll

GeneralRe: Sense of making my own Timestamp class? Pin
Marco Bertschi4-Feb-14 4:03
protectorMarco Bertschi4-Feb-14 4:03 
AnswerRe: Sense of making my own Timestamp class? Pin
jschell4-Feb-14 13:20
jschell4-Feb-14 13:20 
GeneralRe: Sense of making my own Timestamp class? Pin
Marco Bertschi4-Feb-14 20:07
protectorMarco Bertschi4-Feb-14 20:07 
AnswerRe: Sense of making my own Timestamp class? Pin
TnTinMn6-Feb-14 12:37
TnTinMn6-Feb-14 12:37 
GeneralRe: Sense of making my own Timestamp class? Pin
Marco Bertschi6-Feb-14 21:12
protectorMarco Bertschi6-Feb-14 21:12 
GeneralRe: Sense of making my own Timestamp class? Pin
TnTinMn9-Feb-14 10:29
TnTinMn9-Feb-14 10:29 
GeneralRe: Sense of making my own Timestamp class? Pin
Marco Bertschi9-Feb-14 19:56
protectorMarco Bertschi9-Feb-14 19:56 
GeneralRe: Sense of making my own Timestamp class? Pin
TnTinMn10-Feb-14 13:12
TnTinMn10-Feb-14 13:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.