当前位置: 首页>>代码示例>>C#>>正文


C# DateTimeOffset.Humanize方法代码示例

本文整理汇总了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;
 }
开发者ID:Jeff-Lewis,项目名称:CodeBucket,代码行数:7,代码来源:CommentViewModel.cs

示例2: CommentElement

 public CommentElement(string title, string message, DateTimeOffset date, Avatar avatar)
 {
     _title = title;
     _message = message;
     _date = date.Humanize();
     _avatar = avatar;
 }
开发者ID:xNUTs,项目名称:CodeBucket,代码行数:7,代码来源:CommentElement.cs

示例3: CommitElement

 public CommitElement(string name, string description, DateTimeOffset date, Avatar avatar)
 {
     _name = name;
     _description = description;
     _date = date.Humanize();
     _avatar = avatar;
 }
开发者ID:xNUTs,项目名称:CodeBucket,代码行数:7,代码来源:CommitElement.cs

示例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);
 }
开发者ID:RaineriOS,项目名称:CodeHub,代码行数:8,代码来源:CommitCellView.cs

示例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;
 }
开发者ID:Jeff-Lewis,项目名称:CodeBucket,代码行数:8,代码来源:PullRequestElement.cs

示例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);
 }
开发者ID:runt18,项目名称:CodeHub,代码行数:9,代码来源:GistItemViewModel.cs

示例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;
 }
开发者ID:Jeff-Lewis,项目名称:CodeBucket,代码行数:9,代码来源:CommitElement.cs

示例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;
 }
开发者ID:Jeff-Lewis,项目名称:CodeBucket,代码行数:10,代码来源:NameTimeStringElement.cs

示例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);
        }
开发者ID:gabrielrainha,项目名称:Humanizer,代码行数:12,代码来源:DateTimeOffsetHumanizeTests.cs

示例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);
        }
开发者ID:gabrielrainha,项目名称:Humanizer,代码行数:12,代码来源:DateTimeOffsetHumanizeTests.cs

示例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);
        }
开发者ID:gabrielrainha,项目名称:Humanizer,代码行数:12,代码来源:DateTimeOffsetHumanizeTests.cs

示例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);
        }
开发者ID:gabrielrainha,项目名称:Humanizer,代码行数:12,代码来源:DateTimeOffsetHumanizeTests.cs

示例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;
        }
开发者ID:xNUTs,项目名称:CodeBucket,代码行数:16,代码来源:NewsFeedElement.cs

示例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;
        }
开发者ID:Jeff-Lewis,项目名称:CodeBucket,代码行数:16,代码来源:NewsFeedElement.cs

示例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) });
            }
            */
        }
开发者ID:Jeff-Lewis,项目名称:CodeBucket,代码行数:20,代码来源:IssueCellView.cs


注:本文中的DateTimeOffset.Humanize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。