Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion api/src/org/labkey/api/util/DateUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.jetbrains.annotations.Nullable;
import org.junit.Assert;
import org.junit.Test;
import org.labkey.api.collections.CaseInsensitiveHashSet;
import org.labkey.api.data.Container;
import org.labkey.api.data.ContainerManager;
import org.labkey.api.pipeline.PipelineJobService;
Expand Down Expand Up @@ -1368,14 +1369,16 @@ public static String getTimeFormatString(Container c)
return FolderSettingsCache.getDefaultTimeFormat(c);
}

public static final Set<String> META_FORMATS = CaseInsensitiveHashSet.of("Date", "DateTime", "Time");

/**
* Test a date format string to determine if it matches one of LabKey's special named date formats (Date, DateTime, Time)
* @param dateFormat Format string to test
* @return True if the dateFormat matches one of LabKey's special named date formats, otherwise False
*/
public static boolean isSpecialNamedFormat(String dateFormat)
{
return "Date".equals(dateFormat) || "DateTime".equals(dateFormat) || "Time".equals(dateFormat);
return META_FORMATS.contains(dateFormat);
}

private static final FastDateFormat jsonDateFormat = FastDateFormat.getInstance(getJsonDateTimeFormatString());
Expand Down
3 changes: 1 addition & 2 deletions core/src/org/labkey/core/admin/DisplayFormatAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import static org.labkey.api.settings.AbstractSettingsGroup.SITE_CONFIG_USER;
import static org.labkey.api.settings.LookAndFeelFolderProperties.LOOK_AND_FEEL_SET_NAME;
import static org.labkey.api.util.DateUtil.META_FORMATS;

public class DisplayFormatAnalyzer
{
Expand Down Expand Up @@ -98,8 +99,6 @@ public DisplayFormatAnalyzer()
.forEach(candidate -> _propertyCandidateMap.put(candidate.container(), candidate));
}

private static final Set<String> META_FORMATS = CaseInsensitiveHashSet.of("Date", "DateTime", "Time");

// Allows standard formats and standard meta formats
private boolean isNonStandardFormat(DateDisplayFormatType type, String format)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ private void validatePropertyFormat(DomainProperty dp) throws ChangePropertyDesc
if (!StringUtils.isEmpty(dp.getFormat()))
{
String ptype = dp.getRangeURI();
if (ptype.equalsIgnoreCase(PropertyType.DATE_TIME.getTypeUri()))
if (ptype.equalsIgnoreCase(PropertyType.DATE_TIME.getTypeUri())) // TODO: Check Date and Time also?
{
type = " for type " + PropertyType.DATE_TIME.getXarName();
// Allow special named formats (these would otherwise fail validation)
Expand Down