本文整理汇总了C#中DateTimeOffset.Humanize方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimeOffset.Humanize方法的具体用法?C# DateTimeOffset.Humanize怎么用?C# DateTimeOffset.Humanize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeOffset
的用法示例。
在下文中一共展示了DateTimeOffset.Humanize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CommentViewModel
public CommentViewModel(string title, string content, DateTimeOffset created, string avatarUrl)
{
Title = title;
Content = content;
Created = created.Humanize();
AvatarUrl = avatarUrl;
}
示例2: CommentElement
public CommentElement(string title, string message, DateTimeOffset date, Avatar avatar)
{
_title = title;
_message = message;
_date = date.Humanize();
_avatar = avatar;
}
示例3: CommitElement
public CommitElement(string name, string description, DateTimeOffset date, Avatar avatar)
{
_name = name;
_description = description;
_date = date.Humanize();
_avatar = avatar;
}
示例4: Set
public void Set(string title, string description, DateTimeOffset time, GitHubAvatar avatar)
{
ContentConstraint.Constant = string.IsNullOrEmpty(description) ? 0f : DefaultContentConstraintSize;
TitleLabel.Text = title;
ContentLabel.Text = description;
TimeLabel.Text = time.Humanize();
MainImageView.SetAvatar(avatar);
}
示例5: PullRequestElement
public PullRequestElement(string name, DateTimeOffset time, Avatar avatar, UIImage image = null)
: base(null)
{
_name = name;
_time = time.Humanize();
_avatar = avatar;
_image = image ?? Images.Avatar;
}
示例6: GistItemViewModel
public GistItemViewModel(string title, string avatarUrl, string description, DateTimeOffset updatedAt, Action<GistItemViewModel> gotoAction)
{
Title = title;
Description = description;
UpdatedAt = updatedAt;
UpdatedString = UpdatedAt.Humanize();
GoToCommand = ReactiveCommand.Create().WithSubscription(x => gotoAction(this));
Avatar = new GitHubAvatar(avatarUrl);
}
示例7: CommitElement
public CommitElement(string name, string description, DateTimeOffset time, string imageUri = null, UIImage image = null)
: base(null)
{
_name = name;
_description = description;
_time = time.Humanize();
_imageUri = imageUri;
_image = image ?? Images.Avatar;
}
示例8: NameTimeStringElement
public NameTimeStringElement(string name, string description, DateTimeOffset time, string imageUri = null, UIImage image = null, int lines = 0)
: base(null)
{
_name = name;
_description = description;
_time = time.Humanize();
_imageUri = imageUri;
_image = image ?? Images.Avatar;
_lines = (nint)lines;
}
示例9: PrecisionStrategy_DifferentOffsets
public void PrecisionStrategy_DifferentOffsets()
{
Configurator.DateTimeOffsetHumanizeStrategy = new PrecisionDateTimeOffsetHumanizeStrategy(0.75);
var inputTime = new DateTimeOffset(2015, 07, 05, 03, 45, 0, new TimeSpan(2, 0, 0));
var baseTime = new DateTimeOffset(2015, 07, 05, 02, 30, 0, new TimeSpan(-5, 0, 0));
const string expectedResult = "6 hours ago";
var actualResult = inputTime.Humanize(baseTime);
Assert.Equal(expectedResult, actualResult);
}
示例10: PrecisionStrategy_SameOffset
public void PrecisionStrategy_SameOffset()
{
Configurator.DateTimeOffsetHumanizeStrategy = new PrecisionDateTimeOffsetHumanizeStrategy(0.75);
var inputTime = new DateTimeOffset(2015, 07, 05, 04, 0, 0, TimeSpan.Zero);
var baseTime = new DateTimeOffset(2015, 07, 04, 05, 0, 0, TimeSpan.Zero);
const string expectedResult = "tomorrow";
var actualResult = inputTime.Humanize(baseTime);
Assert.Equal(expectedResult, actualResult);
}
示例11: DefaultStrategy_SameOffset
public void DefaultStrategy_SameOffset()
{
Configurator.DateTimeOffsetHumanizeStrategy = new DefaultDateTimeOffsetHumanizeStrategy();
var inputTime = new DateTimeOffset(2015, 07, 05, 04, 0, 0, TimeSpan.Zero);
var baseTime = new DateTimeOffset(2015, 07, 05, 03, 0, 0, TimeSpan.Zero);
const string expectedResult = "an hour from now";
var actualResult = inputTime.Humanize(baseTime);
Assert.Equal(expectedResult, actualResult);
}
示例12: DefaultStrategy_DifferentOffsets
public void DefaultStrategy_DifferentOffsets()
{
Configurator.DateTimeOffsetHumanizeStrategy = new DefaultDateTimeOffsetHumanizeStrategy();
var inputTime = new DateTimeOffset(2015, 07, 05, 03, 0, 0, new TimeSpan(2, 0, 0));
var baseTime = new DateTimeOffset(2015, 07, 05, 02, 30, 0, new TimeSpan(1, 0, 0));
const string expectedResult = "30 minutes ago";
var actualResult = inputTime.Humanize(baseTime);
Assert.Equal(expectedResult, actualResult);
}
示例13: NewsFeedElement
public NewsFeedElement(string imageUrl, DateTimeOffset time, IEnumerable<TextBlock> headerBlocks, IEnumerable<TextBlock> bodyBlocks, UIImage littleImage, Action tapped, bool multilined)
{
Uri.TryCreate(imageUrl, UriKind.Absolute, out _imageUri);
_time = time.Humanize();
_actionImage = littleImage;
_tapped = tapped;
_multilined = multilined;
var header = CreateAttributedStringFromBlocks(UIFont.PreferredBody, Theme.CurrentTheme.MainTextColor, headerBlocks);
_attributedHeader = header.Item1;
_headerLinks = header.Item2;
var body = CreateAttributedStringFromBlocks(UIFont.PreferredSubheadline, Theme.CurrentTheme.MainSubtitleColor, bodyBlocks);
_attributedBody = body.Item1;
_bodyLinks = body.Item2;
}
示例14: NewsFeedElement
public NewsFeedElement(string imageUrl, DateTimeOffset time, IEnumerable<TextBlock> headerBlocks, IEnumerable<TextBlock> bodyBlocks, UIImage littleImage, Action tapped)
: base(null)
{
Uri.TryCreate(imageUrl, UriKind.Absolute, out _imageUri);
_time = time.Humanize();
_actionImage = littleImage;
_tapped = tapped;
var header = CreateAttributedStringFromBlocks(headerBlocks);
_attributedHeader = header.Item1;
_headerLinks = header.Item2;
var body = CreateAttributedStringFromBlocks(bodyBlocks);
_attributedBody = body.Item1;
_bodyLinks = body.Item2;
}
示例15: Bind
public void Bind(string title, string status, string priority, string assigned, DateTimeOffset lastUpdated, string id, string kind)
{
Caption.Text = title;
Label1.Text = status;
Label2.Text = priority;
Label3.Text = assigned;
Label4.Text = lastUpdated.Humanize();
Number.Text = "#" + id;
IssueType.Text = kind;
/*
if (model.CommentCount > 0)
{
var ms = model.CommentCount.ToString ();
var ssize = ms.MonoStringLength(CountFont);
var boxWidth = Math.Min (22 + ssize, 18);
AddSubview(new CounterView(model.CommentCount) { Frame = new RectangleF(Bounds.Width-30-boxWidth, Bounds.Height / 2 - 8, boxWidth, 16) });
}
*/
}