Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 175888

RE: Best solution for time differences between session time and AOS time?

$
0
0

Adrian,

The solution I implemented is system wide, not just prod.

Here is the code I use (I have placed inside the global class).

static date localDate()

{

   System.DateTime utcDate;

   UTCDateTime axUtcDate;

   UTCDateTime localDate;

   CodeAccessPermission permission;

   ;

   permission = new InteropPermission(InteropKind::CLRInterop);

   permission.assert();

   utcDate = System.DateTime::get_UtcNow();

   axUtcDate = DateTimeUtil::anyToDateTime(CLRInterop::getAnyTypeForObject(utcDate));

   localDate = DateTimeUtil::applyTimeZoneOffset(axUtcDate, DateTimeUtil::getCompanyTimeZone());

   CodeAccessPermission::revertAssert();

   return dateTimeUtil::date(localDate);

}

You will notice that the UTCDateTime is converted back into a date in the return call.

Everywhere I want to use local dates you need to convert the code from using SystemDateGet() to LocalDate().

Barry.


Viewing all articles
Browse latest Browse all 175888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>