Skip to content
Episerver property used to store time between 0-24 hours
C# HTML CSS JavaScript PowerShell ASP
Branch: master
Clone or download
Latest commit f94ff0d Aug 21, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets Updated the documentation Aug 21, 2019
build/tools Add automated nuget build Aug 20, 2019
src Updated the documentation Aug 21, 2019
.gitattributes Added Alloy site demo Aug 19, 2019
.gitignore Add automated nuget build Aug 20, 2019
LICENSE Initial commit Aug 19, 2019
README.md Updated the documentation Aug 21, 2019
pack.cmd Add automated nuget build Aug 20, 2019
pack.ps1 Fixed pack script Aug 21, 2019

README.md

Advanced CMS

time-property

Episerver property used to store time between 0-24 hours for Episerver v11.x

Property is stored in the model as a Timespan type. It's using dijit/form/TimeTextBox as an editor in Edit Mode.

Preview unpublished content

Getting Started

First install Advanced.CMS.TimeProperty package from EPiServer's NuGet feed.

PM> Install-Package Advanced.CMS.TimeProperty

Then add new TimeSpan property to your content model. The property needs to be annotated with BackingType attribute.

[ContentType(GUID = "AREDS8A41-5C8C-G3PJ-8F74-320ZF3DE8227")]
public class TestPage : PageData
{
    [BackingType(typeof(AdvancedCms.TimeProperty.TimeProperty))]
    public virtual TimeSpan? Time1 { get; set; }
}

Edit mode configuration

By default the editor will be displayed using 12-hour clock time format. To change this you can use TimePropertySettings attribute added on the model. For example, to get 24-hour clock format:

[ContentType(GUID = "AREDS8A41-5C8C-G3PJ-8F74-320ZF3DE8227")]
public class TestPage : PageData
{
    [BackingType(typeof(AdvancedCms.TimeProperty.TimeProperty))]
    [TimePropertySettings(TimePattern = "HH:mm")]
    public virtual TimeSpan? Time1 { get; set; }
}

Then it will be rendered as:

Preview unpublished content

View mode property renderer

Nuget contains renderer for the view mode. You need to use PropertyFor and TimeSpan tag:

@Html.PropertyFor(x => x.CurrentPage.Time1, new { Tag = "TimeSpan" })

Preview unpublished content

To render time with custom format use DateFormat property:

@Html.PropertyFor(x => x.CurrentPage.Time1, new { DateFormat = "hh:mm tt", Tag = "TimeSpan" })

Preview unpublished content

You can’t perform that action at this time.