mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
Support for localizing datetimes base on browser's timezone
This commit is contained in:
committed by
nicolas.dorier
parent
556082c4c9
commit
63ec832667
@@ -425,7 +425,7 @@ namespace BTCPayServer.Controllers
|
|||||||
{
|
{
|
||||||
Status = invoice.Status + (invoice.ExceptionStatus == null ? string.Empty : $" ({invoice.ExceptionStatus})"),
|
Status = invoice.Status + (invoice.ExceptionStatus == null ? string.Empty : $" ({invoice.ExceptionStatus})"),
|
||||||
ShowCheckout = invoice.Status == "new",
|
ShowCheckout = invoice.Status == "new",
|
||||||
Date = (DateTimeOffset.UtcNow - invoice.InvoiceTime).Prettify() + " ago",
|
Date = invoice.InvoiceTime,
|
||||||
InvoiceId = invoice.Id,
|
InvoiceId = invoice.Id,
|
||||||
OrderId = invoice.OrderId ?? string.Empty,
|
OrderId = invoice.OrderId ?? string.Empty,
|
||||||
RedirectUrl = invoice.RedirectURL ?? string.Empty,
|
RedirectUrl = invoice.RedirectURL ?? string.Empty,
|
||||||
|
|||||||
@@ -33,10 +33,7 @@ namespace BTCPayServer.Models.InvoicingModels
|
|||||||
|
|
||||||
public class InvoiceModel
|
public class InvoiceModel
|
||||||
{
|
{
|
||||||
public string Date
|
public DateTimeOffset Date { get; set; }
|
||||||
{
|
|
||||||
get; set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string OrderId { get; set; }
|
public string OrderId { get; set; }
|
||||||
public string RedirectUrl { get; set; }
|
public string RedirectUrl { get; set; }
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
@foreach(var invoice in Model.Invoices)
|
@foreach(var invoice in Model.Invoices)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>@invoice.Date</td>
|
<td>@invoice.Date.BrowserDate()</td>
|
||||||
<td>
|
<td>
|
||||||
@if(invoice.RedirectUrl != string.Empty)
|
@if(invoice.RedirectUrl != string.Empty)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Html;
|
||||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||||
|
|
||||||
namespace BTCPayServer.Views
|
namespace BTCPayServer.Views
|
||||||
@@ -22,5 +24,11 @@ namespace BTCPayServer.Views
|
|||||||
var activePage = (T)viewData[ACTIVE_PAGE_KEY];
|
var activePage = (T)viewData[ACTIVE_PAGE_KEY];
|
||||||
return page.Equals(activePage) ? "active" : null;
|
return page.Equals(activePage) ? "active" : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HtmlString BrowserDate(this DateTimeOffset date)
|
||||||
|
{
|
||||||
|
var hello = date.ToString("o", CultureInfo.InvariantCulture);
|
||||||
|
return new HtmlString($"<span class='localizeDate'>{hello}</span>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,8 @@
|
|||||||
"wwwroot/vendor/jquery-easing/jquery.easing.js",
|
"wwwroot/vendor/jquery-easing/jquery.easing.js",
|
||||||
"wwwroot/vendor/scrollreveal/scrollreveal.min.js",
|
"wwwroot/vendor/scrollreveal/scrollreveal.min.js",
|
||||||
"wwwroot/vendor/magnific-popup/jquery.magnific-popup.js",
|
"wwwroot/vendor/magnific-popup/jquery.magnific-popup.js",
|
||||||
"wwwroot/vendor/bootstrap4-creativestart/*.js"
|
"wwwroot/vendor/bootstrap4-creativestart/*.js",
|
||||||
|
"wwwroot/main/**/*.js"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
9
BTCPayServer/wwwroot/main/site.js
Normal file
9
BTCPayServer/wwwroot/main/site.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
$(function () {
|
||||||
|
$(".localizeDate").each(function (index) {
|
||||||
|
var serverDate = $(this).text();
|
||||||
|
var localDate = new Date(serverDate);
|
||||||
|
|
||||||
|
var dateString = localDate.toLocaleDateString() + " " + localDate.toLocaleTimeString();
|
||||||
|
$(this).text(dateString);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user