public override object BeforeMethod(string method)
        {
            switch (method)
            {
            case "day": return(ConvertDate.ToFa(_dateTime, " d "));

            case "hour": return(ConvertDate.ToFa(_dateTime, "hh"));

            case "minute": return(ConvertDate.ToFa(_dateTime, "mm"));

            case "year": return(ConvertDate.ToFa(_dateTime, "yyyy"));

            case "month": return(ConvertDate.ToFa(_dateTime, "MM"));

            case "week_day_name": return(_dateTime.ToString("dddd", Thread.CurrentThread.CurrentCulture));

            case "month_name": return(ConvertDate.ToFa(_dateTime, " d "));

            case "full": return(_dateTime.ToString("dddd dd MMMM yyy"));

            case "from_now": return(_dateTime.ToUniversalTime().Humanize(culture: Thread.CurrentThread.CurrentCulture));
            }

            return(base.BeforeMethod(method));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Debug.WriteLine(ConvertDate.ToFa(DateTime.Now));      //1393/08/01

            Debug.WriteLine(ConvertDate.ToFa(DateTime.Now, "d")); //93/08/01
            Debug.WriteLine(ConvertDate.ToFa(DateTime.Now, "D")); //پنج شنبه, 01 آبان 1393

            Debug.WriteLine(ConvertDate.ToFa(DateTime.Now, "t")); //21:53
            Debug.WriteLine(ConvertDate.ToFa(DateTime.Now, "T")); //21:53:26

            Debug.WriteLine(ConvertDate.ToFa(DateTime.Now, "g")); //93/08/01 21:53
            Debug.WriteLine(ConvertDate.ToFa(DateTime.Now, "G")); //93/08/01 21:53:26


            Debug.WriteLine(ConvertDate.ToFa(DateTime.Now, "f")); //پنج شنبه, 01 آبان 1393 21:53
            Debug.WriteLine(ConvertDate.ToFa(DateTime.Now, "F")); //پنج شنبه, 01 آبان 1393 21:53:26

            Debug.WriteLine(ConvertDate.ToFa(DateTime.Now, "m")); //آبان 1
            Debug.WriteLine(ConvertDate.ToFa(DateTime.Now, "M")); //

            Debug.WriteLine(ConvertDate.ToFa(DateTime.Now, "y")); //1393 آبان
            Debug.WriteLine(ConvertDate.ToFa(DateTime.Now, "Y")); //1393 آبان
            //new standard formats
            Debug.WriteLine("new standard formats ");
            Debug.WriteLine(ConvertDate.ToFa(DateTime.Now, "yy MMM"));          //93 آبان
            Debug.WriteLine(ConvertDate.ToFa(DateTime.Now, "yyyy/MM/dd "));     //1393/8/9
            Debug.WriteLine(ConvertDate.ToFa(DateTime.Now, "yy-M-d "));         //93-8-09
            Debug.WriteLine(ConvertDate.ToFa(DateTime.Now, "ddd dd MMM yyyy")); //جمعه 9 آبان 1393

            //testing convert back to DateTime from persian string
            Debug.WriteLine("ToEn test (testing convert back to DateTime from persian string) ");

            Debug.WriteLine(ConvertDate.ToEn("1393/08/01")); //2014/10/23 00:00:00
            Debug.WriteLine(ConvertDate.ToEn("01/8/1393"));  //2014/10/23 00:00:00
            Debug.WriteLine(ConvertDate.ToEn("1/8/1393"));   //2014/10/23 00:00:00
            Debug.WriteLine(ConvertDate.ToEn("1-8-93"));     //2014/10/23 00:00:00
            Debug.WriteLine(ConvertDate.ToEn("93-8-01"));    //2014/10/23 00:00:00
            Debug.WriteLine(ConvertDate.ToEn("93 8 01"));    //2014/10/23 00:00:00
            //extra spaces and different separators are handled
            Debug.WriteLine(ConvertDate.ToEn("1_8_1393 "));  //2014/10/23 00:00:00
            Debug.WriteLine(ConvertDate.ToEn(" 1_8_1393 ")); //2014/10/23 00:00:00
            Debug.WriteLine(ConvertDate.ToEn(" 1.8.1393 ")); //2014/10/23 00:00:00


            Console.WriteLine("check visual studio output window");
            Console.WriteLine("press any key to continue");
            Console.ReadKey();
        }
Exemplo n.º 3
0
        public async Task <FileListResponse> Get(FileGetListRequest request)
        {
            var files = _fileDataService.Query.Filter(request.Query).OrderByDescending(x => x.CreateDateTime).AsQueryable();

            return(new FileListResponse
            {
                Access = ResponseAccess.Granted,
                FilesData = (await files.Paginate(request.Query).MapListToViewModelWithMeta(_metaDataService.Query))
                            .GroupBy(x => x.CreateDateTime.Date,
                                     x => x,
                                     (key, group) =>
                                     new GroupedByDateFile
                {
                    DateTime = ConvertDate.ToFa(key, "yyyy/MM/dd"),
                    Files = group.ToList()
                })
                            .OrderByDescending(x => x.DateTime)
                            .ToList()
            });
        }
Exemplo n.º 4
0
 private void HandleShipmentChanges(Shipment oldShipment, Shipment updatedShipment, Guid orderId)
 {
     if (oldShipment is null)
     {
         if (updatedShipment.DeliveryDate.HasValue)
         {
             AddOrderLog($"تاریخ رسیدن به محصول به دست مشتری به {ConvertDate.ToFa(updatedShipment.DeliveryDate, "yyyy/MM/dd - hh:mm")}  تغییر یافت.", orderId);
         }
         if (updatedShipment.ShippedDate.HasValue)
         {
             AddOrderLog($"تاریخ ارسال مرسوله به {ConvertDate.ToFa(updatedShipment.DeliveryDate, "yyyy/MM/dd - hh:mm")}  تغییر یافت.", orderId);
         }
         if (!string.IsNullOrEmpty(updatedShipment.AdminComment))
         {
             AddOrderLog($"نظر ادمین برای حمل و نقل تغییر یافت", orderId);
         }
         if (!string.IsNullOrEmpty(updatedShipment.TrackingNumber))
         {
             AddOrderLog($"شماره پیگیری حمل و نقل تغییر یافت", orderId);
         }
     }
     else
     {
         if (updatedShipment.DeliveryDate != oldShipment.DeliveryDate)
         {
             AddOrderLog($"تاریخ رسیدن محصول به دست مشتری از {ConvertDate.ToFa(oldShipment.DeliveryDate, "yyyy/MM/dd - hh:mm")} به {ConvertDate.ToFa(updatedShipment.DeliveryDate, "yyyy/MM/dd - hh:mm")} تغییر یافت.", orderId);
         }
         if (updatedShipment.ShippedDate != oldShipment.ShippedDate)
         {
             AddOrderLog($"تاریخ ارسال مرسوله از {ConvertDate.ToFa(oldShipment.ShippedDate, "yyyy/MM/dd - hh:mm")} به {ConvertDate.ToFa(updatedShipment.ShippedDate, "yyyy/MM/dd - hh:mm")}  تغییر یافت.", orderId);
         }
         if (updatedShipment.AdminComment != oldShipment.AdminComment)
         {
             AddOrderLog($"نظر ادمین برای حمل و نقل تغییر یافت", orderId);
         }
         if (updatedShipment.TrackingNumber != oldShipment.TrackingNumber)
         {
             AddOrderLog($"شماره پیگیری حمل و نقل از {oldShipment.TrackingNumber} به {updatedShipment.TrackingNumber} تغییر یافت.", orderId);
         }
     }
 }
 public string Convert(DateTime source, string destination, ResolutionContext context)
 {
     return(ConvertDate.ToFa(source, "yyyy/MM/dd - hh:mm"));
 }
 public string Convert(DateTime?source, string destination, ResolutionContext context)
 {
     return(source.HasValue? ConvertDate.ToFa(source, "yyyy/MM/dd - hh:mm"):"");
 }