Skip to main content
Solved

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

  • 23 November 2020
  • 1 reply
  • 167 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 };
    }
}

View original
Did this topic help you find an answer to your question?

1 reply

Hughes Beausejour
Acumatica Employee
Forum|alt.badge.img+2
  • Acumatica Developer Support Team
  • 91 replies
  • 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 };
    }
}


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings