TimeZone Offset Data

Hello,

We have several companies located around the globe and I’d like to be able to calculate local time based on server time. Site Maintenance has a setting for time zone, which includes a UTC offset value…

…but what is stored on the Plant table is the TimeZoneID, which is only the text description…

Site configuration has a “Time Zone Offset” value, but it appears that it is no longer maintained…

Any idea where Epicor is getting this UTC offset value? I’d like to access it in BAQs.

Thanks,
Michael Thompson

If Epicor is not providing enough detail then I would suggest you use an ice.UD## table and store your site ID and off set for GMT there. Then you can query as needed or join to calculate your time.

Josh,

Thanks for the input, I was hoping not to burn a UD table for this and the information is already in Epicor somewhere (Isn’t it?). That said, your post gives me an idea.

We have the UDCodes table (user codes) for simple, categorized name/value pairs. But sometimes, we need more than two values. In this case, I need the long name name such as Eastern Standard Time, an abbreviation (EST), the UTC offset +/- #, and, if I really wanted to get geeky with it, accommodations for distinctions between daylight savings and standard time for US time zones–that is another value or two.

I could store these extra values in the long description field in some kind of parsable format or, perhaps even better, I could add some UD fields to the UDCodes table that would include a handful of additional fields with labels for each that could be displayed in the UI.

If I can figure out where this data is in Epicor, it may inspire me to go down this road instead.

Regards,

Michael

Can we take a step back please - What are you attempting to do?

The Time Zone value on both the Company and Plant contains the Windows Time Zone ID. From that, you can easily get the UTC offset and with that, the offset from the Company to the Plant. The original “Offset” value that was on Plant was problematic particularly if Company or Plant existed in a locale with different rules for Daylight Savings.

What is the end goal?

2 Likes

Rich,

As always, I appreciate your input.

I must be missing something–how can I get the UTC offset in a BAQ with only the Windows Time Zone ID? Is there a function within the BAQ editor that I am missing?

The end goal is to be able to include local time references in BAQs and Dashboards.

Michael

In my poking I’ve seen an Epicor Time Helper class, I do believe this one was of the functions available.

Chris,

Thanks for pointing me in a direction. Looks like I will have to learn how to do some “poking” myself. Yay, more things to learn!

I’ll take a closer look this week and see if I can figure it ot.

Thanks!

Michael

I looked for 0.5 seconds and did not see the Epicor Time Helper class, but I figured because this is still the only post I can see with this topic that I would post this snip of code here for anyone that might need it. I am not looking at the daylight savings time flag in my example, but this is also something you can pull from the plant record:

// Adjust for plant timezone
var timezoneID = (from row in Db.Plant
                 where row.Company == callContextClient.CurrentCompany
                    && row.PlantID == callContextClient.CurrentPlant
                select row.TimeZoneID).FirstOrDefault();
if(timeZoneID != null)
{
  DateTime currentTime = DateTime.Now;
  TimeSpan serverUtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(currentTime);
  TimeSpan plantUtcOffset = TimeZoneInfo.FindSystemTimeZoneById(timezoneID).GetUtcOffset(currentTime);
  TimeSpan serverToPlantOffset = serverUtcOffset.Subtract(plantUtcOffset);
  DateTime plantToday = currentTime.Subtract(serverToPlantOffset).Date;
  DateTime plantNow = currentTime.Subtract(serverToPlantOffset);
 // Other stuff here
}
2 Likes

Helper Methods available in BPMs, BAQs, EFx

Ice.Lib.CompanyTime.Today(CompanyID);
Ice.Lib.CompanyTime.Today(); // CurrentCompany Defaulted
Ice.Lib.CompanyTime.Now(CompanyID);
Ice.Lib.CompanyTime.Now(); // CurrentCompany Defaulted
2 Likes

I’d like to add:
var sitetime = Ice.Lib.TimeZone.GetSiteLocalTime();
Dont forget to import it.

2 Likes

This is probably only relevant from the the fact that TZs are involved, but the Task Agent Schedules can run in their own time zone and if empty then it just uses the TZ of the app server.

This is a true statement, it does rely on Company\Site timezones to be set.

1 Like

Since we’re necroposting… have any of you seen issues with sending in dates (with no time) and the date coming back out with a “Time zone” shifted date?

This BAQ is just taking a date parameter, and spitting it back out as a calculated field.

Even better, V1 doesn’t do the time zone hokey pokey. Kinetic still uses V1 in most of their screens (BAD EPICOR!) so you wouldn’t see this unless you are using the REST V2 api, which we are. And it’s causing stupid annoying problems that we don’t haven’t found a great way to fix.

keanu reeves vampire GIF

Holy moley - so it just decides to shift your input date?

I saw some posts about timezone settings in REST headers yesterday while scouring, I wonder if any of those are relevant. Let me see if I can accidentally find them again.

Here’s one:

Well, that’s the same issue, not resolved. Haha.

1 Like

:rofl:

If you just put the input date param into a calc field (unless thats what you already did), does it shift that too?

That’s what this BAQ is.

Do you guys have TZs set on Comps and Sites?

We do. It doesn’t seem to follow those. It uses the server time zone, not the plant one.

I am all for hacky workarounds, I’ve built my hopes and dreams on them. You could possibly just pass a string and parse that bad boy yourself.