public override void OnBind(MessageData message)
 {
     if (time != null)
     {
         time.Text = DateFormatter.Format(message.CreatedAt, DateFormatter.Template.TIME);
     }
 }
        public override void OnBind(Java.Lang.Object p0)
        {
            base.OnBind(p0);
            var message = (ChatKitQs.Src.Common.Data.Models.Message)p0;

            tvDuration.Text = FormatUtils.GetDurationString(message.MessageVoice.Duration);
            tvTime.Text     = DateFormatter.Format(message.CreatedAt, DateFormatter.Template.Time);
        }
 protected internal String DoFallback(long duration, long referenceDate)
 {
     if (fallback != null && fallbackLimit > 0 &&
         Math.Abs(duration) >= fallbackLimit)
     {
         return(fallback.Format(referenceDate + duration));
     }
     return(null);
 }
Exemple #4
0
        static void Main(string[] args)
        {
            var formatter = new DateFormatter();

            string formatedNow = formatter.Format(DateTime.Now);

            Console.WriteLine(formatedNow);
            Console.ReadLine();
        }
 /// <summary>
 /// Map a conference to an generic item
 /// </summary>
 /// <param name="element">Conference to map</param>
 /// <returns>Corresponding generic item</returns>
 public VisualGenericItem Map(Conference element)
 {
     return(new VisualGenericItem
     {
         Id = element.Id,
         Title = element.Name,
         Subtitle = string.Format("{0}, {1}", element.Campus.Place, DateFormatter.Format(element.Start_DateTime)),
         ImageUrl = element.ImageUrl,
         Type = element.GetType().Name
     });
 }
        public void Format_GivenDateString_ShouldReturnFormattedString()
        {
            // Arrange.
            var testObject = new DateFormatter("d MMM (ddd)");

            // Act.
            string result = testObject.Format("2019-7-1");

            // Assert.
            Assert.AreEqual("1 Jul (Mon)", result);
        }
Exemple #7
0
 /// <summary>
 /// Map a show to an generic item
 /// </summary>
 /// <param name="element">Show to map</param>
 /// <returns>Corresponding generic item</returns>
 public VisualGenericItem Map(Show element)
 {
     return(new VisualGenericItem
     {
         Id = element.Id,
         Title = element.Name,
         Subtitle = DateFormatter.Format(element.Start_DateTime),
         ImageUrl = element.ImageUrl,
         Type = element.GetType().Name
     });
 }
 public override ICharSequence ConvertObject(object value)
 {
     if (value is ICharSequence seq)
     {
         return(seq);
     }
     if (value is DateTime time)
     {
         return(new StringCharSequence(DateFormatter.Format(time)));
     }
     return(new StringCharSequence(value.ToString()));
 }
 public override void OnBind(MessageData date)
 {
     if (text != null)
     {
         string formattedDate = null;
         if (dateHeadersFormatter != null)
         {
             formattedDate = dateHeadersFormatter.Format(date.CreatedAt);
         }
         text.Text = string.ReferenceEquals(formattedDate, null) ? DateFormatter.Format(date.CreatedAt, DateFormatter.Template.TIME) : formattedDate;
     }
 }
        public void Format_GivenNonDateString_ShouldReturnStringUnchanged()
        {
            // Arrange.
            var testObject = new DateFormatter("d MMM (ddd)");

            const string input = "2019-7-x";

            // Act.
            string result = testObject.Format(input);

            // Assert.
            Assert.AreEqual(input, result);
        }
Exemple #11
0
 /// <summary>
 /// Map a news to an generic item
 /// </summary>
 /// <param name="element">News to map</param>
 /// <returns>Corresponding generic item</returns>
 public VisualGenericItem Map(News element)
 {
     return(new VisualGenericItem
     {
         Id = element.Id,
         Title = element.Title,
         Subtitle = string.Format("{0}, {1} {2} {3}", DateFormatter.Format(element.DateTime),
                                  AppResourcesHelper.GetString("BY"),
                                  element.Member.FirstName,
                                  element.Member.LastName),
         ImageUrl = element.ImageUrl,
         Type = element.GetType().Name
     });
 }
Exemple #12
0
            public override ICharSequence ConvertObject(object value)
            {
                switch (value)
                {
                case ICharSequence seq:
                    return(seq);

                case DateTime time:
                    return(new StringCharSequence(DateFormatter.Format(time)));

                default:
                    return(new StringCharSequence(value.ToString()));
                }
            }
        public void DecodingSingleCookieV0()
        {
            string cookieString = "myCookie=myValue;expires="
                                  + DateFormatter.Format(DateTime.UtcNow.AddMilliseconds(50000))
                                  + ";path=/apathsomewhere;domain=.adomainsomewhere;secure;";
            ICookie cookie = ClientCookieDecoder.StrictDecoder.Decode(cookieString);

            Assert.NotNull(cookie);

            Assert.Equal("myValue", cookie.Value);
            Assert.Equal(".adomainsomewhere", cookie.Domain);
            Assert.True(cookie.MaxAge >= 40 && cookie.MaxAge <= 60, "maxAge should be about 50ms when parsing cookie " + cookieString);
            Assert.Equal("/apathsomewhere", cookie.Path);
            Assert.True(cookie.IsSecure);
        }
Exemple #14
0
 public string Format(Date p0)
 {
     if (DateFormatter.IsToday(p0))
     {
         return(GetString(Resource.String.date_header_today));
     }
     else if (DateFormatter.IsYesterday(p0))
     {
         return(GetString(Resource.String.date_header_yesterday));
     }
     else
     {
         return(DateFormatter.Format(p0, DateFormatter.Template.StringDayMonthYear));
     }
 }
Exemple #15
0
        /// <summary>
        /// Add 5 last news on the tile
        /// </summary>
        /// <returns>The notification for the tile</returns>
        private async Task <TileNotification> AddNewsToTileAsync()
        {
            // Resolve the model
            using (ILifetimeScope scope = ViewModelLocator.Container.BeginLifetimeScope())
            {
                // Get news from model
                IReadableLimitable <News> model = scope.Resolve <IReadableLimitable <News> >();
                IList <News> newsList           = await model.GetAsync(0, ItemsNumber);

                // Create the tile
                if (newsList.Count == ItemsNumber)
                {
                    var  random = new Random();
                    int  index  = random.Next(0, ItemsNumber);
                    News news   = newsList[index];

                    // Create the square tile
                    ITileSquarePeekImageAndText02 squareContent = TileContentFactory.CreateTileSquarePeekImageAndText02();

                    // Square tile text
                    squareContent.TextHeading.Text  = DateFormatter.Format(news.DateTime);
                    squareContent.TextBodyWrap.Text = news.Title;

                    // Square tile image
                    squareContent.Image.Src = news.ImageUrl;
                    squareContent.Image.Alt = news.Title;

                    // Create the wide tile
                    ITileWideSmallImageAndText04 wideContent = TileContentFactory.CreateTileWideSmallImageAndText04();

                    // Link the square tile and the wide tile
                    wideContent.SquareContent = squareContent;

                    // Wide tile text
                    wideContent.TextHeading.Text  = DateFormatter.Format(news.DateTime);
                    wideContent.TextBodyWrap.Text = news.Title;

                    // Wide tile image
                    wideContent.Image.Src = news.ImageUrl;
                    wideContent.Image.Alt = news.Title;

                    return(wideContent.CreateNotification());
                }
            }

            return(null);
        }
Exemple #16
0
        static void Main(string[] args)
        {
            //string a = "Hi";
            //StringBuilder b = new StringBuilder();

            //Console.WriteLine($"variable {nameof(a)}  is from {TypeUtils.GetNameSpace(a)}");
            //Console.WriteLine($"variable {nameof(b)}  is from {TypeUtils.GetNameSpace(b)}");

            //Console.WriteLine("Press Enter to exit");
            //Console.ReadLine();''

            var formatter = new DateFormatter();

            string formatNow = formatter.Format(DateTime.Now);

            Console.WriteLine(formatNow);
        }
            public override void OnBind(MessageData message)
            {
                if (time != null)
                {
                    time.Text = DateFormatter.Format(message.CreatedAt, DateFormatter.Template.TIME);
                }

                if (userAvatar != null)
                {
                    bool isAvatarExists = imageLoader != null && message.User.Avatar != null && !string.IsNullOrEmpty(message.User.Avatar);

                    userAvatar.Visibility = isAvatarExists ? ViewStates.Visible : ViewStates.Gone;
                    if (isAvatarExists)
                    {
                        imageLoader.LoadImage(userAvatar, message.User.Avatar);
                    }
                }
            }
Exemple #18
0
 public string Format(Date date)
 {
     if (DateFormatter.IsToday(date))
     {
         return(DateFormatter.Format(date, DateFormatter.Template.Time));
     }
     else if (DateFormatter.IsYesterday(date))
     {
         return(GetString(Resource.String.date_header_yesterday));
     }
     else if (DateFormatter.IsCurrentYear(date))
     {
         return(DateFormatter.Format(date, DateFormatter.Template.StringDayMonth));
     }
     else
     {
         return(DateFormatter.Format(date, DateFormatter.Template.StringDayMonthYear));
     }
 }
 public string FormatHttpHeaderDateFormatter() => DateFormatter.Format(this.date);
 public string Format(DateFormatter formatter)
 {
     return(formatter.Format(this.Value));
 }
Exemple #21
0
 public void Format()
 {
     Assert.Equal("Sun, 06 Nov 1994 08:49:37 GMT", DateFormatter.Format(_expectedTime));
 }
Exemple #22
0
 protected string GetDateString(DateTime date)
 {
     return(DateFormatter.Format(date, DateFormatter.Template.STRING_DAY_MONTH_YEAR_TIME));
 }
Exemple #23
0
        /// <summary>
        /// Add 5 last shows on the tile
        /// </summary>
        /// <returns>The notification for the tile</returns>
        private async Task <TileNotification> AddShowsToTileAsync()
        {
            // Resolve model
            using (ILifetimeScope scope = ViewModelLocator.Container.BeginLifetimeScope())
            {
                // Get the shows from the model
                IReadableLimitable <Show> model = scope.Resolve <IReadableLimitable <Show> >();
                IList <Show> shows = await model.GetAsync(0, ItemsNumber);

                // Create the square tile if there is one show available
                if (shows.Any())
                {
                    ITileSquarePeekImageAndText02 squareContent = TileContentFactory.CreateTileSquarePeekImageAndText02();
                    squareContent.TextHeading.Text  = ResourcesAccessor.GetString("Shows_Small");
                    squareContent.TextBodyWrap.Text = shows[0].Name;
                    squareContent.Image.Src         = shows[0].ImageUrl;
                    squareContent.Image.Alt         = shows[0].Name;

                    // Create the wide tile if there are enough elements
                    if (shows.Count == ItemsNumber)
                    {
                        ITileWidePeekImageCollection05 wideContent = TileContentFactory.CreateTileWidePeekImageCollection05();

                        // Link the square tile and the wide tile
                        wideContent.SquareContent = squareContent;

                        // Text
                        wideContent.TextHeading.Text  = ResourcesAccessor.GetString("Shows_Long");
                        wideContent.TextBodyWrap.Text = string.Format("{0} ({1})", shows[0].Name, DateFormatter.Format(shows[0].Start_DateTime));

                        // ImageUrls
                        wideContent.ImageMain.Src = shows[0].ImageUrl;
                        wideContent.ImageMain.Alt = shows[0].Name;

                        wideContent.ImageSecondary.Src = shows[0].ImageUrl;
                        wideContent.ImageSecondary.Alt = shows[0].Name;

                        wideContent.ImageSmallColumn1Row1.Alt = shows[1].Name;
                        wideContent.ImageSmallColumn1Row1.Src = shows[1].ImageUrl;

                        wideContent.ImageSmallColumn1Row2.Alt = shows[2].Name;
                        wideContent.ImageSmallColumn1Row2.Src = shows[2].ImageUrl;

                        wideContent.ImageSmallColumn2Row1.Alt = shows[3].Name;
                        wideContent.ImageSmallColumn2Row1.Src = shows[3].ImageUrl;

                        wideContent.ImageSmallColumn2Row2.Alt = shows[4].Name;
                        wideContent.ImageSmallColumn2Row2.Src = shows[4].ImageUrl;

                        return(wideContent.CreateNotification());
                    }
                }
            }

            return(null);
        }