本文整理汇总了C#中System.DateTime.?.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.?.ToString方法的具体用法?C# DateTime.?.ToString怎么用?C# DateTime.?.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DateTime
的用法示例。
在下文中一共展示了DateTime.?.ToString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Schedule
public ActionResult Schedule(DateTime? date, ScheduleEditModel model)
{
var modelsForUpdate = model.Buckets
.SelectMany(b => b.Games.Where(g => g.HomeParticipant != null &&
g.RoadParticipant != null &&
(g.HomeParticipant.RunsScored != 0 || g.RoadParticipant.RunsScored != 0)))
.ToList();
var gameIds = modelsForUpdate.Select(g => g.GameId)
.ToArray();
var toUpdate = DbContext.Games
.Where(g => gameIds.Contains(g.GameId))
.ToList()
.Join(modelsForUpdate, g => g.GameId, m => m.GameId, (g, m) => new {Game = g, Model = m});
foreach (var row in toUpdate)
{
row.Game.GameStatusId = GameStatus.Final;
row.Game.RoadParticipant.RunsScored = row.Model.RoadParticipant.RunsScored;
row.Game.HomeParticipant.RunsScored = row.Model.HomeParticipant.RunsScored;
row.Game.IsFinalized = true;
row.Game.AddResultReportFromLeague();
}
DbContext.SaveChanges(User.Identity.GetUserId());
return RedirectToAction("Schedule", new { date = date?.ToString(Consts.DateFormat) });
}
示例2: SendTemplateAsync
public Task<IList<MandrillSendMessageResponse>> SendTemplateAsync(MandrillMessage message, string templateName,
IList<MandrillTemplateContent> templateContent = null, bool async = false,
string ipPool = null, DateTime? sendAtUtc = null)
{
if (message == null) throw new ArgumentNullException(nameof(message));
if (templateName == null) throw new ArgumentNullException(nameof(templateName));
if (sendAtUtc != null && sendAtUtc.Value.Kind != DateTimeKind.Utc)
{
throw new ArgumentException("date must be in utc", nameof(sendAtUtc));
}
return
MandrillApi.PostAsync<MandrillSendMessageRequest, IList<MandrillSendMessageResponse>>(
"messages/send-template.json",
new MandrillSendTemplateRequest
{
Message = message,
TemplateName = templateName,
TemplateContent = templateContent?.ToList(),
Async = async,
IpPool = ipPool,
SendAt = sendAtUtc?.ToString(SendAtDateFormat)
});
}
示例3: Get
/// <summary>
/// Returns statistics of a community or an application.
/// </summary>
/// <param name="groupId">Community ID. </param>
/// <param name="appId">Application ID. </param>
/// <param name="dateFrom">Latest date of statistics to return.</param>
/// <param name="dateTo">End date of statistics to return.</param>
/// <returns>Returns a <see cref="List{T}"/> of <see cref="Period"/> objects.</returns>
public async Task<Response<List<Period>>> Get(int? groupId = null, int? appId = null, DateTime? dateFrom = null,
DateTime? dateTo = null) => await Request<List<Period>>("get", new MethodParams
{
{"group_id", groupId},
{"app_id", appId},
{"date_from", dateFrom?.ToString("yyyy-MM-dd")},
{"date_to", dateTo?.ToString("yyyy-MM-dd")}
});
示例4: Schedule
public ActionResult Schedule(DateTime? date)
{
var model = _scheduleService.GetScheduleModelForDate(date);
if (model == null)
{
return HttpNotFound($"No games found for {date?.ToString(Consts.DateFormatDisplay)}.");
}
return View(model);
}
示例5: GetEventAnalyticsTimelineAsync
public async Task<AnalyticsTimelineResponse> GetEventAnalyticsTimelineAsync(bool distinct = false, AnalyticsTimelineGroup group = AnalyticsTimelineGroup.Day, DateTime? from = default(DateTime?), DateTime? to = default(DateTime?), string userId = null, string name = null)
{
var additionalParams = new Dictionary<string, string>();
additionalParams.Add(nameof(distinct), distinct.ToString().ToLowerInvariant());
additionalParams.Add(nameof(group), group.ToString().ToLowerInvariant());
if (from != null) additionalParams.Add(nameof(from), $"{from?.ToString("yyyy-MM-ddTHH:mm:ss.fff")}Z");
if (to != null) additionalParams.Add(nameof(to), $"{to?.ToString("yyyy-MM-ddTHH:mm:ss.fff")}Z");
if (userId != null) additionalParams.Add("user_id", userId);
if (name != null) additionalParams.Add(nameof(name), name);
return await HttpConnection.GetAsync<AnalyticsTimelineResponse>("/analytics/events/timeline", additionalParams);
}
示例6: ActivityAsync
public async Task<MandrillExportInfo> ActivityAsync(string notifyEmail,
DateTime? dateFrom = null,
DateTime? dateTo = null,
IList<string> tags = null,
IList<string> senders = null,
IList<string> states = null,
IList<string> apiKeys = null)
{
return await MandrillApi.PostAsync<MandrillExportRequest, MandrillExportInfo>("exports/activity",
new MandrillExportRequest
{
NotifyEmail = notifyEmail,
DateFrom = dateFrom?.ToString(ActivityDateFormat),
DateTo = dateTo?.ToString(ActivityDateFormat),
Tags = tags?.ToList(),
Senders = senders?.ToList(),
States = states?.ToList(),
ApiKeys = apiKeys?.ToList()
});
}
示例7: SendRawAsync
public Task<IList<MandrillSendMessageResponse>> SendRawAsync(string rawMessage, string fromEmail = null,
string fromName = null, IList<string> to = null, bool? async = null,
string ipPool = null, DateTime? sendAtUtc = null, string returnPathDomain = null)
{
if (rawMessage == null) throw new ArgumentNullException(nameof(rawMessage));
return
MandrillApi.PostAsync<MandrillSendRawMessageRequest, IList<MandrillSendMessageResponse>>(
"messages/send-raw.json",
new MandrillSendRawMessageRequest
{
RawMessage = rawMessage,
FromEmail = fromEmail,
FromName = fromName,
To = to?.ToList(),
Async = async,
IpPool = ipPool,
SendAt = sendAtUtc?.ToString(SendAtDateFormat),
ReturnPathDomain = returnPathDomain
});
}
示例8: DateTimePicker
public static MvcHtmlString DateTimePicker(this HtmlHelper helper, string name, bool formGroup, DateTime? value, string dateTimeFormat, CultureInfo culture = null, IDictionary<string, object> htmlProps = null)
{
var dateFormat = SplitDateTimeFormat(dateTimeFormat, culture);
if (dateFormat.TimeFormat == null)
return helper.DatePicker(name, formGroup, value?.ToString(dateFormat.DateFormat, culture), ToJsDateFormat(dateFormat.DateFormat), culture, htmlProps);
if(dateFormat.DateFormat == null)
return helper.TimePicker(name, formGroup, value?.ToString(dateFormat.TimeFormat, culture), dateFormat.TimeFormat, htmlProps);
HtmlStringBuilder sb = new HtmlStringBuilder();
using (sb.SurroundLine(new HtmlTag("div", name).Class("date-time")))
{
sb.Add(helper.DatePicker(TypeContextUtilities.Compose(name, "Date"), formGroup, value?.ToString(dateFormat.DateFormat, culture), ToJsDateFormat(dateFormat.DateFormat), culture, htmlProps));
sb.Add(helper.TimePicker(TypeContextUtilities.Compose(name, "Time"), formGroup, value?.ToString(dateFormat.TimeFormat, culture), dateFormat.TimeFormat, htmlProps));
}
return sb.ToHtml();
}
示例9: SearchAsync
public Task<IList<MandrillMessageInfo>> SearchAsync(string query, DateTime? dateFrom = null,
DateTime? dateTo = null, IList<string> tags = null, IList<string> senders = null,
IList<string> apiKeys = null, int? limit = null)
{
return
MandrillApi.PostAsync<MandrillMessageSearchRequest, IList<MandrillMessageInfo>>("messages/search.json",
new MandrillMessageSearchRequest
{
DateFrom = dateFrom?.ToString(SearchDateFormat),
DateTo = dateTo?.ToString(SearchDateFormat),
Query = query,
Tags = tags?.ToList(),
Senders = senders?.ToList(),
ApiKeys = apiKeys?.ToList(),
Limit = limit
});
}
示例10: SearchTimeSeriesAsync
public Task<IList<MandrillMessageTimeSeries>> SearchTimeSeriesAsync(string query, DateTime? dateFrom = null,
DateTime? dateTo = null, IList<string> tags = null,
IList<string> senders = null)
{
return
MandrillApi.PostAsync<MandrillMessageSearchRequest, IList<MandrillMessageTimeSeries>>(
"messages/search-time-series.json",
new MandrillMessageSearchRequest
{
DateFrom = dateFrom?.ToString(SearchDateFormat),
DateTo = dateTo?.ToString(SearchDateFormat),
Query = query,
Tags = tags?.ToList(),
Senders = senders?.ToList()
});
}
示例11: FormatDate
public static string FormatDate(DateTime? date)
{
return date?.ToString("MM/dd/yyyy");
}
示例12: GetFormattedDate
public static string GetFormattedDate(DateTime? date) => date?.ToString(format: DateFormat) ?? string.Empty;
示例13: Iso8601
/// <summary>
/// Type-safe helper method for R.Iso8601
/// </summary>
public Iso8601 Iso8601(DateTime? datetime)
{
var str = datetime?.ToString("o");
return Ast.Iso8601.FromString(str);
}