@Html.ActionLink(T("Add or remove supported cultures for the site.").ToString(), "Culture")
+
@Html.EditorFor(x => x.PageTitleSeparator)
diff --git a/src/Orchard.Web/Core/Shapes/DateTimeShapes.cs b/src/Orchard.Web/Core/Shapes/DateTimeShapes.cs
index 7270d01fa..ab9c39fa6 100644
--- a/src/Orchard.Web/Core/Shapes/DateTimeShapes.cs
+++ b/src/Orchard.Web/Core/Shapes/DateTimeShapes.cs
@@ -7,22 +7,27 @@ using Orchard.Mvc.Html;
using Orchard.Services;
namespace Orchard.Core.Shapes {
- public class DateTimeShapes : ISingletonDependency {
+ public class DateTimeShapes : IDependency {
private readonly IClock _clock;
+ private readonly IWorkContextAccessor _workContextAccessor;
- public DateTimeShapes(IClock clock) {
+ public DateTimeShapes(
+ IClock clock,
+ IWorkContextAccessor workContextAccessor
+ ) {
_clock = clock;
+ _workContextAccessor = workContextAccessor;
T = NullLocalizer.Instance;
}
public Localizer T { get; set; }
[Shape]
- public IHtmlString DateTimeRelative(HtmlHelper Html, DateTime dateTimeUtc) {
+ public IHtmlString DateTimeRelative(dynamic Display, DateTime dateTimeUtc) {
var time = _clock.UtcNow - dateTimeUtc;
if (time.TotalDays > 7)
- return Html.DateTime(dateTimeUtc.ToLocalTime(), T("'on' MMM d yyyy 'at' h:mm tt"));
+ return Display.DateTime(DateTimeUtc: dateTimeUtc, CustomFormat: T("'on' MMM d yyyy 'at' h:mm tt"));
if (time.TotalHours > 24)
return T.Plural("1 day ago", "{0} days ago", time.Days);
if (time.TotalMinutes > 60)
@@ -34,5 +39,30 @@ namespace Orchard.Core.Shapes {
return T("a moment ago");
}
+
+ [Shape]
+ public IHtmlString DateTime(DateTime DateTimeUtc, LocalizedString CustomFormat) {
+ //using a LocalizedString forces the caller to use a localizable format
+
+ if (CustomFormat == null || String.IsNullOrWhiteSpace(CustomFormat.Text)) {
+ return DateTime(DateTimeUtc, T("MMM d yyyy h:mm tt"));
+ }
+
+ return new MvcHtmlString(ConvertToDisplayTime(DateTimeUtc).ToString(CustomFormat.Text));
+ }
+
+ ///
+ /// Converts a Coordinated Universal Time (UTC) to the time in the current time zone.
+ ///
+ ///
The Coordinated Universal Time (UTC).
+ ///
The date and time in the selected time zone. Its System.DateTime.Kind property is System.DateTimeKind.Utc if the current zone is System.TimeZoneInfo.Utc; otherwise, its System.DateTime.Kind property is System.DateTimeKind.Unspecified.
+ private DateTime ConvertToDisplayTime(DateTime dateTimeUtc) {
+
+ // get the time zone for the current request
+ var timeZone = _workContextAccessor.GetContext().CurrentTimeZone;
+
+ return TimeZoneInfo.ConvertTimeFromUtc(dateTimeUtc, timeZone);
+ }
+
}
}
diff --git a/src/Orchard.Web/Modules/Orchard.ArchiveLater/Views/Parts/ArchiveLater.Metadata.SummaryAdmin.cshtml b/src/Orchard.Web/Modules/Orchard.ArchiveLater/Views/Parts/ArchiveLater.Metadata.SummaryAdmin.cshtml
index 35d3625f1..a9b35ac90 100644
--- a/src/Orchard.Web/Modules/Orchard.ArchiveLater/Views/Parts/ArchiveLater.Metadata.SummaryAdmin.cshtml
+++ b/src/Orchard.Web/Modules/Orchard.ArchiveLater/Views/Parts/ArchiveLater.Metadata.SummaryAdmin.cshtml
@@ -4,7 +4,7 @@
-
@T("Unpublish on")
- @Html.DateTime((DateTime)Model.ScheduledArchiveUtc.ToLocalTime(), T("M/d/yyyy h:mm tt"))
+ @Display.DateTime(DateTimeUtc: (DateTime)Model.ScheduledArchiveUtc.ToLocalTime(), CustomFormat: T("M/d/yyyy h:mm tt"))
|
diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Views/Admin/Details.cshtml b/src/Orchard.Web/Modules/Orchard.Comments/Views/Admin/Details.cshtml
index 990ad322f..b63376f7f 100644
--- a/src/Orchard.Web/Modules/Orchard.Comments/Views/Admin/Details.cshtml
+++ b/src/Orchard.Web/Modules/Orchard.Comments/Views/Admin/Details.cshtml
@@ -83,7 +83,7 @@
@text
}
-
@Html.DateTime(commentEntry.Comment.CommentDateUtc.GetValueOrDefault()) |
+
@Display.DateTime(DateTimeUtc: commentEntry.Comment.CommentDateUtc.GetValueOrDefault()) |
-
diff --git a/src/Orchard.Web/Modules/Orchard.Comments/Views/Admin/Index.cshtml b/src/Orchard.Web/Modules/Orchard.Comments/Views/Admin/Index.cshtml
index 1c198ee97..3e8fba850 100644
--- a/src/Orchard.Web/Modules/Orchard.Comments/Views/Admin/Index.cshtml
+++ b/src/Orchard.Web/Modules/Orchard.Comments/Views/Admin/Index.cshtml
@@ -77,7 +77,7 @@
|
@* would ideally have permalinks for individual comments *@
-
+
@if (commentEntry.Comment.CommentText != null) {
var ellipsized = Html.Ellipsize(commentEntry.Comment.CommentText, 500);
var paragraphed = new HtmlString(ellipsized.ToHtmlString().Replace("\r\n", ""));
diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Field.cshtml b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Field.cshtml
index 3ff3ecd17..bdc552a4a 100644
--- a/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Field.cshtml
+++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Views/EditorTemplates/Field.cshtml
@@ -2,8 +2,8 @@
|