Options

Email Logging - UTC date Conversion

MauddibMauddib Member Posts: 269
edited 2015-08-10 in NAV Three Tier
Hi all, any ideas on this one?

All client computers and Server computers are set to UTC + 1 Time Zones. Navision 2015.

Email logging CU5064 has a function as follows:
UpdateSegLine(VAR SegLine : Record "Segment Line";Emails : Code[10];Subject : Text;DateSent : DotNet "System.DateTime";DateReceived : DotNet "System.DateTime";AttachmentNo : Integer)
InformationFlow := SegLine."Information Flow";
SegLine.VALIDATE("Interaction Template Code",Emails);
SegLine."Information Flow" := InformationFlow;
SegLine."Correspondence Type" := SegLine."Correspondence Type"::"E-Mail";
SegLine.Description := COPYSTR(Subject,1,MAXSTRLEN(SegLine.Description));

IF SegLine."Information Flow" = SegLine."Information Flow"::Outbound THEN BEGIN
  LineDate := DateSent;
  SegLine."Initiated By" := SegLine."Initiated By"::Us;
END ELSE BEGIN
  LineDate := DateReceived;
  SegLine."Initiated By" := SegLine."Initiated By"::Them;
END;

// The date received from Exchange is UTC and to record the UTC date and time
// using the AL functions requires datetime to be of the local date time kind.
LineDate := LineDate.DateTime(LineDate.Ticks,DateTimeKind.Local);
SegLine.Date := DT2DATE(LineDate);
SegLine."Time of Interaction" := DT2TIME(LineDate);

SegLine.Subject := COPYSTR(Subject,1,MAXSTRLEN(SegLine.Subject));
SegLine."Attachment No." := AttachmentNo;
SegLine.MODIFY;

Problem is: The Date it is returning is 2 hours in the past. That is to say if the email was received at 1600, the code is putting 1400 into SegLine.Date.

Is there an error in this code here? Or is it possible (how to check this) that Exchange is NOT giving UTC time as the code expects?

If I change the DateTimeKind.Local to DateTimeKind.Utc then I get the correct result!!! But I would rather not change the code if the error lies elsewhere.

Comments

  • Options
    Wisa123Wisa123 Member Posts: 308
    I expect you already checked wheather the ServiceUser has some weird Time-Settings?

    Else i'd suggest to just quickly fire up VisualStudio and try it on your own, but to be honest, changing it from local to utc is an ok change if it works for you imo.

    /wisa
    Austrian NAV/BC Dev
Sign In or Register to comment.