本文整理汇总了C#中System.Date.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Date.ToString方法的具体用法?C# Date.ToString怎么用?C# Date.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Date
的用法示例。
在下文中一共展示了Date.ToString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportRaw
public string ExportRaw(ClientConfiguration clientConfiguration, Date from, Date to, string[] events = null)
{
try
{
var uri = MixPanelEndpointConfiguration.RawExportUrl;
var parameterDictionary = new Dictionary<string, string>();
parameterDictionary.Add(FromDateParamName, from.ToString());
parameterDictionary.Add(ToDateParamName, to.ToString());
if (events != null
&& events.Any())
parameterDictionary.Add(EventParamName, StringifyEvents(events));
var callingUri =
new Uri(uri.ToString() + "?" + string.Join("&", parameterDictionary.Select(x => x.Key + "=" + x.Value)));
var webClientResponse = _webClient.QueryUri(callingUri,
new BasicAuthentication { UserName = clientConfiguration.Secret });
return webClientResponse;
}
catch (WebException ex)
{
TryHandleWebException(ex);
throw new MixPanelClientException(ex);
}
catch (Exception ex)
{
throw new MixPanelClientException(ex);
}
}
示例2: GetPrintNumber
// GetLeMondePrintNumber
public static int GetPrintNumber(Date date)
{
// Le monde - 2012-12-02 - no 21110.pdf
// Le monde - 2012-10-12 - no 21066.pdf
// Le monde - 2012-07-19 - no 20993.pdf
// pas de journal le 1er mai sauf si c'est un dimanche, journal le dimanche 1er mai 2011
// Test_GetLeMondePrintNumber("2012-04-29"); // ok 20925
// Test_GetLeMondePrintNumber("2012-05-02"); // ok 20926
Date dateRef = new Date(2012, 12, 2);
int noRef = 21110;
while (date > dateRef)
{
if (dateRef.DayOfWeek != DayOfWeek.Sunday && (dateRef.Month != 5 || dateRef.Day != 1 || dateRef.DayOfWeek == DayOfWeek.Sunday))
noRef++;
dateRef = dateRef.AddDays(1);
}
while (date < dateRef)
{
if (dateRef.DayOfWeek != DayOfWeek.Monday && (dateRef.Month != 5 || dateRef.Day != 1 || dateRef.DayOfWeek == DayOfWeek.Sunday))
noRef--;
dateRef = dateRef.AddDays(-1);
}
if (date != dateRef) throw new PBException("error date not found {0}", date.ToString());
return noRef;
}
示例3: GetDirectory
public string GetDirectory(Date date)
{
string format = null;
switch (Type)
{
case PrintDirectoryDateStorageType.YearSubDirectory:
format = "yyyy";
break;
case PrintDirectoryDateStorageType.MonthSubDirectory:
format = "yyyy-MM";
break;
case PrintDirectoryDateStorageType.DaySubDirectory:
format = "yyyy-MM-dd";
break;
}
if (format != null)
return Prefix + date.ToString(format);
else
return null;
}
示例4: GetExpectedUrl
private Uri GetExpectedUrl(Date defaultStartDate, Date defaultEndDate, string @event)
{
var stringifiedUrl =
$"{MixPanelEndpointConfiguration.RawExportUrl}?from_date={defaultStartDate.ToString()}&to_date={defaultEndDate.ToString()}&event=[\"{HttpUtility.UrlEncode(@event)}\"]";
return new Uri(stringifiedUrl);
}
示例5: BuildString
private static string BuildString(Date modifiedDate, TimeOfDay modifiedTime,
Date? nullableModifiedDate, TimeOfDay? nullableModifiedTime)
{
StringBuilder sb = new StringBuilder();
sb.Append("modifiedDate:").Append(modifiedDate).Append(",");
sb.Append("modifiedTime:").Append(modifiedTime).Append(",");
sb.Append("nullableModifiedDate:").Append(nullableModifiedDate == null ? "null" : nullableModifiedDate.ToString()).Append(",");
sb.Append("nullableModifiedTime:").Append(nullableModifiedTime == null ? "null" : nullableModifiedTime.ToString());
return sb.ToString();
}
示例6: to_string_uses_the_ugly_ddMMyyyy_format
public void to_string_uses_the_ugly_ddMMyyyy_format()
{
var date = new Date(2, 22, 2012);
date.ToString().ShouldEqual("22022012");
}
示例7: WriteValue
/// <summary>
/// Write a Date value
/// </summary>
/// <param name="writer">The text writer to write the output to.</param>
/// <param name="value">Date value to be written.</param>
internal static void WriteValue(TextWriter writer, Date value)
{
Debug.Assert(writer != null, "writer != null");
WriteQuoted(writer, value.ToString());
}
示例8: ToString
/// <summary>
/// Converts the given Date value to the string appropriate for Atom format.
/// </summary>
/// <param name="date">The Date value to convert.</param>
/// <returns>The string version of the Date in Atom format.</returns>
internal static string ToString(Date date)
{
return date.ToString();
}
示例9: DateAsXml
/// <summary>
/// Converts the Date to a String.
/// </summary>
/// <param name="d">The <see cref="Microsoft.OData.Edm.Library.Date"/> to be converted</param>
/// <returns>A System.String representation of the supplied <see cref="Microsoft.OData.Edm.Library.Date"/>.</returns>
internal static string DateAsXml(Date d)
{
var value = d.ToString();
return value;
}
示例10: ToStringFormat
public void ToStringFormat(string expected, int year, int month, int day)
{
var value = new Date(year, month, day);
Assert.AreEqual(expected, value.ToString());
}
示例11: CanPresentSortablePattern
public void CanPresentSortablePattern()
{
using (new CultureScope(CultureInfo.InvariantCulture))
{
Date d = new Date(2013, 4, 5);
string s = d.ToString("s");
Assert.AreEqual("2013-04-05", s);
}
}
示例12: CanPresentRoundTripPattern
public void CanPresentRoundTripPattern()
{
using (new CultureScope(CultureInfo.InvariantCulture))
{
Date d = new Date(2013, 4, 5);
string s1 = d.ToString("O");
string s2 = d.ToString("o");
Assert.AreEqual(s1, s2);
Assert.AreEqual("2013-04-05", s1);
Assert.AreEqual("2013-04-05", s2);
}
}