Making DateTimeRelative an extension method

--HG--
branch : dev
This commit is contained in:
Renaud Paquay
2010-10-18 17:21:42 -07:00
parent ee8f511484
commit 1bda590fda
11 changed files with 63 additions and 41 deletions

View File

@@ -9,7 +9,7 @@
}
<ul class="pageStatus">
<li>@if (modifiedUtc.HasValue) {
@T("Last modified: {0}", Html.DateTimeRelative(modifiedUtc.Value, T))}&nbsp;&#124;&nbsp;
@T("Last modified: {0}", Display.DateTimeRelative(dateTime: modifiedUtc.Value))}&nbsp;&#124;&nbsp;
</li>
<li>@T("By {0}", owner.UserName)</li>
</ul>

View File

@@ -6,5 +6,5 @@
DateTime? versionPublishedUtc = publishLaterPart.As<CommonPart>() == null ? null : publishLaterPart.As<CommonPart>().VersionPublishedUtc;
}
@if (publishLaterPart.IsPublished() && versionPublishedUtc.HasValue) {
@T("Published: {0}", Html.DateTimeRelative(versionPublishedUtc.Value, T)) @T(" | ")
@T("Published: {0}", Display.DateTimeRelative(versionPublishedUtc.Value)) @T(" | ")
}

View File

@@ -26,7 +26,7 @@
@if ((((DateTime?)Model.ScheduledPublishUtc).HasValue && ((DateTime?)Model.ScheduledPublishUtc).Value > DateTime.UtcNow) || (publishLaterPart.IsPublished() && versionPublishedUtc.HasValue)) {
<li>
@if (publishLaterPart.IsPublished() && versionPublishedUtc.HasValue) {
@T("Published: {0}", Html.DateTimeRelative(versionPublishedUtc.Value, T))
@T("Published: {0}", Display.DateTimeRelative(versionPublishedUtc.Value))
}
else {
<img class="icon" src="@Href("~/Core/PublishLater/Content/Admin/images/scheduled.gif")" alt="@T("Scheduled")" title="@T("The page is scheduled for publishing")" /><text> @T("Scheduled") </text>

View File

@@ -6,5 +6,5 @@
DateTime? versionPublishedUtc = publishLaterPart.As<CommonPart>() == null ? null : publishLaterPart.As<CommonPart>().VersionPublishedUtc;
}
@if (publishLaterPart.IsPublished() && versionPublishedUtc.HasValue) {
@T("Published: {0}", Html.DateTimeRelative(versionPublishedUtc.Value, T))
@T("Published: {0}", Display.DateTimeRelative(dateTime: versionPublishedUtc.Value))
}

View File

@@ -3,19 +3,19 @@
<ul class="comments">
@foreach (var comment in Model) {
<li>
<article class="comment">
<header>
<h4>
<span class="who">@Html.LinkOrDefault(comment.Record.UserName, comment.Record.SiteName, new { rel = "nofollow" })
</span>
<span class="when">said <time datetime="@comment.Record.CommentDateUtc.GetValueOrDefault()">@Html.Link(Html.DateTimeRelative(comment.Record.CommentDateUtc.GetValueOrDefault(), T).ToString(), "#")</time>
</span>
</h4>
</header>
<p class="text">@comment.Record.CommentText</p>
</article>
</li>
<li>
<article class="comment">
<header>
<h4>
<span class="who">@Html.LinkOrDefault(comment.Record.UserName, comment.Record.SiteName, new { rel = "nofollow" })
</span>
<span class="when">said <time datetime="@comment.Record.CommentDateUtc.GetValueOrDefault()">@Html.Link(Display.DateTimeRelative(dateTime: comment.Record.CommentDateUtc.GetValueOrDefault()).ToString(), "#")</time>
</span>
</h4>
</header>
<p class="text">@comment.Record.CommentText</p>
</article>
</li>
}
</ul>

View File

@@ -20,7 +20,7 @@
<p>@T("The search index contains the following fields: {0}.", string.Join(T(", ").Text, Model.IndexEntry.Fields))</p>
}
<p>@T("The search index was last updated {0}.", Html.DateTimeRelative(Model.IndexEntry.LastUpdateUtc.Value, T))</p>
<p>@T("The search index was last updated {0}.", Display.DateTimeRelative(dateTime: Model.IndexEntry.LastUpdateUtc.Value))</p>
}
<p>@T("Update the search index now: ")<button type="submit" title="@T("Update the search index.")" class="primaryAction">@T("Update")</button></p>
@Html.AntiForgeryTokenOrchard()

View File

@@ -7,7 +7,7 @@ foreach (var comment in Model) { %>
<p><%: comment.Record.CommentText %></p>
</div>
<div class="commentauthor">
<span class="who"><%: Html.LinkOrDefault(Html.Encode(comment.Record.UserName), Html.Encode(comment.Record.SiteName), new { rel = "nofollow" })%></span>&nbsp;<span>said <%: Html.Link(Html.DateTimeRelative(comment.Record.CommentDateUtc.GetValueOrDefault(), T).Text, "#")%></span>
<span class="who"><%: Html.LinkOrDefault(Html.Encode(comment.Record.UserName), Html.Encode(comment.Record.SiteName), new { rel = "nofollow" })%></span>&nbsp;<span>said <%: Html.Link(Display.DateTimeRelative(dateTime: comment.Record.CommentDateUtc.GetValueOrDefault()).Text, "#")%></span>
</div>
</li><%
} %>

View File

@@ -7,7 +7,7 @@ foreach (var comment in Model) { %>
<p><%: comment.Record.CommentText %></p>
</div>
<div class="commentauthor">
<span class="who"><%: Html.LinkOrDefault(comment.Record.UserName, comment.Record.SiteName, new { rel = "nofollow" })%></span>&nbsp;<span>said <%: Html.Link(Html.DateTimeRelative(comment.Record.CommentDateUtc.GetValueOrDefault(), T).Text, "#")%></span>
<span class="who"><%: Html.LinkOrDefault(comment.Record.UserName, comment.Record.SiteName, new { rel = "nofollow" })%></span>&nbsp;<span>said <%: Html.Link(Display.DateTimeRelative(dateTime: comment.Record.CommentDateUtc.GetValueOrDefault()).Text, "#")%></span>
</div>
</li><%
} %>