From c19c61fb8610c17af72712e798330c9bbad9f00f Mon Sep 17 00:00:00 2001 From: roman-yagodin Date: Fri, 16 Mar 2018 12:21:21 +0300 Subject: [PATCH] Close GH-12 Introduce Now and UtcNow props --- R7.Dnn.Extensions/ViewModels/ViewModelContext.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/R7.Dnn.Extensions/ViewModels/ViewModelContext.cs b/R7.Dnn.Extensions/ViewModels/ViewModelContext.cs index 2d0b464..fdc556c 100644 --- a/R7.Dnn.Extensions/ViewModels/ViewModelContext.cs +++ b/R7.Dnn.Extensions/ViewModels/ViewModelContext.cs @@ -4,7 +4,7 @@ // Author: // Roman M. Yagodin // -// Copyright (c) 2015-2017 Roman M. Yagodin +// Copyright (c) 2015-2018 Roman M. Yagodin // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by @@ -19,6 +19,8 @@ // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see . +using System; +using System.Web; using System.Web.UI; using DotNetNuke.Services.Localization; using DotNetNuke.UI.Modules; @@ -43,6 +45,16 @@ public class ViewModelContext /// The module instance context. public ModuleInstanceContext Module { get; protected set; } + /// + /// Gets the initial timestamp of the current HTTP request. + /// + public DateTime Now => HttpContext.Current.Timestamp; + + /// + /// Gets the initial timestamp of the current HTTP request in UTC. + /// + public DateTime UtcNow => HttpContext.Current.Timestamp.ToUniversalTime (); + /// /// Initializes a new instance of the class. ///