static void VKUTCToLocalDateTime(Args _args) { timeZone timeZone = timeZone::GMT_DUBLIN_EDINBURGH_LISBON_LONDON; // DateTimeUtil::getUserPreferredTimeZone(); utcDateTime standardDateTime = 2019-01-07T07:42:59, // winter time, standard daylightDateTime = 2019-07-10T10:42:59, // summer time, DST, daylight saving time localDateTime; container infoContainer; utcdatetime dayLightStartDate; utcdatetime dayLightEndDate; TimeBias standardBias; TimeBias dayLightBias; TimeZoneId timeZoneId; // Easy conversion to local time // from UTC to GMT/BST (GB/UK/London); localDateTime = DateTimeUtil::applyTimeZoneOffset(standardDateTime, timeZone); localDateTime = DateTimeUtil::applyTimeZoneOffset(daylightDateTime, timeZone); // Hard way conversion daylightDateTime to local time, but with more control // Get timezone information container infoContainer = DateTimeUtil::populateTimeZoneInfo(DateTimeUtil::year(daylightDateTime), timeZone); dayLightStartDate = conPeek(infoContainer, 1); dayLightEndDate = conPeek(infoContainer, 2); standardBias = conPeek(infoContainer, 3); dayLightBias = conPeek(infoContainer, 4); // cumulative // substract time bias // https://stackoverflow.com/questions/2779948/subroutine-to-apply-daylight-bias-to-display-time-in-local-dst localDateTime = DateTimeUtil::addMinutes(daylightDateTime, -standardBias); if (daylightDateTime >= dayLightStartDate && daylightDateTime <= dayLightEndDate) { localDateTime = DateTimeUtil::addMinutes(localDateTime, -dayLightBias); } // UTC date time standardDateTime = DateTimeUtil::utcNow(); // system date time standardDateTime = DateTimeUtil::getSystemDateTime(); // Change the timezone information standardDateTime = DateTimeUtil::removeTimeZoneOffset(localDateTime, timeZone); localDateTime = DateTimeUtil::applyTimeZoneOffset(standardDateTime, timeZone::GMTPLUS0200HELSINKI_KYIV_RIGA_VILNIUS); // Timezone timeZone = DateTimeUtil::getUserPreferredTimeZone(); timeZoneId = DateTimeUtil::getTimeZoneId(timeZone); // \Classes\RetailTimeZoneInfoJob\updateTimezoneInfoTable // Standard table TimezoneInfo is populated with timezone information }
DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.
Authors are allowed to set their own AdSense units.
Join us.