Example #1
0
        public _DateChangeModel SetDateTime(DateTime? date)
        {
            this.DateTimeFriendly = date.FromNow(null);
            this.DateTimeISO8601 = date.ToISO8601();
            this.DateTimeUnixEpoc = date.ToUnixEpoc() ?? -1;
            this.DateTimeFull = date.ToFullDateTime(null);

            return this;
        }
 public void ToISO8601Test()
 {
     var timestamp = new DateTime(1918, 11, 11, 11, 00, 00, DateTimeKind.Utc);
     Assert.AreEqual(timestamp.ToISO8601(), "19181111T11:00:00+0000");
 }
 internal string GetAuthorizationHeaderValue(ClientCredential credential, DateTime timestamp, string authData, string requestData)
 {
     string signingKey = timestamp.ToISO8601().ToByteArray().ComputeKeyedHash(credential.Secret, this.SignVersion.Algorithm).ToBase64();
     string authSignature = string.Format("{0}{1}", requestData, authData).ToByteArray().ComputeKeyedHash(signingKey, this.SignVersion.Algorithm).ToBase64();
     return string.Format("{0}signature={1}", authData, authSignature);
 }
public static System.Web.WebPages.HelperResult FriendlyDate(DateTime d, string ElementId = null, bool WithoutSuffix = false)
{
#line default
#line hidden
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
WriteLiteralTo(__razor_helper_writer, "<span ");


#line 12 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(__razor_helper_writer, ElementId == null ? null : new HtmlString(string.Format("id=\"{0}\" ", ElementId)));


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "title=\"");


#line 12 "..\..\App_Code\CommonHelpers.cshtml"
                                                                     WriteTo(__razor_helper_writer, d.ToFullDateTime());


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "\" data-livestamp=\"");


#line 12 "..\..\App_Code\CommonHelpers.cshtml"
                                                                                                          WriteTo(__razor_helper_writer, d.ToUnixEpoc());


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "\" data-isodate=\"");


#line 12 "..\..\App_Code\CommonHelpers.cshtml"
                                                                                                                                         WriteTo(__razor_helper_writer, d.ToISO8601());


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "\" class=\"date nowrap");


#line 12 "..\..\App_Code\CommonHelpers.cshtml"
                                                                                                                                                                            WriteTo(__razor_helper_writer, WithoutSuffix ? " noMomentSuffix" : null);


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "\">");


#line 12 "..\..\App_Code\CommonHelpers.cshtml"
                                                                                                                                                                                                                        WriteTo(__razor_helper_writer, d.ToFullDateTime());


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "</span>");


#line 12 "..\..\App_Code\CommonHelpers.cshtml"
                                                                                                                                                                                                                                                                                

#line default
#line hidden
});

#line 12 "..\..\App_Code\CommonHelpers.cshtml"
}
        internal string GetAuthDataValue(ClientCredential credential, DateTime timestamp)
        {
            if (timestamp == null)
                throw new ArgumentNullException("timestamp cannot be null");

            Guid nonce = Guid.NewGuid();
            return string.Format("{0} client_token={1};access_token={2};timestamp={3};nonce={4};",
                this.SignVersion.Name,
                credential.ClientToken,
                credential.AccessToken,
                timestamp.ToISO8601(),
                nonce.ToString().ToLower());
        }