Skip to main content
Answer

What is the purpose of this DAC: PX.SM.StandartDateTimeFormat

  • November 23, 2020
  • 1 reply
  • 185 views

What is the purpose of this DAC?

 

 PX.SM.StandartDateTimeFormat

I used it in a generic inquiry and it displayed the day and time according to my site timezone.

Am I using it correctly? How else can it be used? I’d like to know if anyone is using it. 

 

 

Best answer by Hughes Beausejour

It’s used as a base DAC in PXStandartDateTimeFormatSelectorAttribute to return multiple date time patterns.

 

The selector takes the date time format parameter:

[PXStandartDateTimeFormatSelectorAttribute('D')]

 

That value is passed as Code parameter to .NET Framework GetAllDateTimePatterns.

The multiple patterns are stored in the PX.SM.StandartDateTimeFormat.Pattern field.

protected virtual IEnumerable GetRecords()
{
    if (Cache == null || Cache.Current == null) yield break;
    PX.SM.LocaleFormat row = Cache.Current as PX.SM.LocaleFormat;

    CultureInfo culture = null;
    if (row != null && !String.IsNullOrEmpty(row.TemplateLocale))
        culture = CultureInfo.GetCultureInfo(row.TemplateLocale);
    if (culture == null) culture = CultureInfo.CurrentCulture;

    foreach (String pattern in culture.DateTimeFormat.GetAllDateTimePatterns(Code))
    {
        yield return new PX.SM.StandartDateTimeFormat() { Pattern = pattern };
    }
}

1 reply

Hughes Beausejour
Acumatica Employee
Forum|alt.badge.img+2
  • Acumatica Developer Support Team
  • Answer
  • November 23, 2020

It’s used as a base DAC in PXStandartDateTimeFormatSelectorAttribute to return multiple date time patterns.

 

The selector takes the date time format parameter:

[PXStandartDateTimeFormatSelectorAttribute('D')]

 

That value is passed as Code parameter to .NET Framework GetAllDateTimePatterns.

The multiple patterns are stored in the PX.SM.StandartDateTimeFormat.Pattern field.

protected virtual IEnumerable GetRecords()
{
    if (Cache == null || Cache.Current == null) yield break;
    PX.SM.LocaleFormat row = Cache.Current as PX.SM.LocaleFormat;

    CultureInfo culture = null;
    if (row != null && !String.IsNullOrEmpty(row.TemplateLocale))
        culture = CultureInfo.GetCultureInfo(row.TemplateLocale);
    if (culture == null) culture = CultureInfo.CurrentCulture;

    foreach (String pattern in culture.DateTimeFormat.GetAllDateTimePatterns(Code))
    {
        yield return new PX.SM.StandartDateTimeFormat() { Pattern = pattern };
    }
}