Esempio n. 1
0
        private IPhpValue TranslateAddInterval(IExternalTranslationContext ctx, CsharpMethodCallExpression src, int mnoznik)
        {
            var intervalString = GetIntervalString(ctx, src.Arguments[0], mnoznik);
            var interval       = PhpMethodCallExpression.MakeConstructor("DateInterval", null, intervalString);

            interval.DontIncludeClass = true;
            var targetObject = ctx.TranslateValue(src.TargetObject);
            var methd        = new PhpMethodCallExpression("date_add", null, targetObject, interval);

            return(methd);
        }
Esempio n. 2
0
 public IPhpValue TranslateToPhp(IExternalTranslationContext ctx, CallConstructor src)
 {
     if (src.Info.DeclaringType != typeof(DateTime))
     {
         return(null);
     }
     switch (src.Info.ToString())
     {
     case "Void .ctor(Int32, Int32, Int32)":
     {
         //                $date = new DateTime();
         //$date->setDate(2001, 2, 3);
         var dtObject = PhpMethodCallExpression.MakeConstructor("DateTime", null);
         dtObject.DontIncludeClass = true;
         // date_date_set
         var b = new PhpMethodCallExpression("date_date_set",
                                             dtObject,
                                             ctx.TranslateValue(src.Arguments[0]),
                                             ctx.TranslateValue(src.Arguments[1]),
                                             ctx.TranslateValue(src.Arguments[2])
                                             );
         var c = new PhpMethodCallExpression("date_time_set",
                                             b,
                                             new PhpConstValue(0),
                                             new PhpConstValue(0),
                                             new PhpConstValue(0)
                                             );
         var mktime = new PhpMethodCallExpression("mktime",
                                                  new PhpConstValue(0),
                                                  new PhpConstValue(0),
                                                  new PhpConstValue(0),
                                                  ctx.TranslateValue(src.Arguments[1]), //month
                                                  ctx.TranslateValue(src.Arguments[2]), // day
                                                  ctx.TranslateValue(src.Arguments[0])  // year
                                                  );
         var epoch = new PhpBinaryOperatorExpression(".", new PhpConstValue("@"), mktime);
         dtObject.Arguments.Add(new PhpMethodInvokeValue(epoch));
         return(dtObject);
         // int mktime ([ int $hour = date("H") [, int $minute = date("i") [, int $second = date("s") [, int $month = date("n") [, int $day = date("j") [, int $year = date("Y") [, int $is_dst = -1 ]]]]]]] )
         // $datetimeobject = new DateTime(mktime(0, 0, 0, $data[$j]['month'], $data[$j]['day'],$data[$j]['year']));
     }
     }
     throw new NotImplementedException();
 }
Esempio n. 3
0
        public IPhpValue TranslateToPhp(IExternalTranslationContext ctx, ClassPropertyAccessExpression src)
        {
            if (src.Member.DeclaringType != typeof(DateTime))
            {
                return(null);
            }
            switch (src.Member.Name)
            {
            case "Now":
            {
                // $date = new DateTime('2000-01-01');
                var c = PhpMethodCallExpression.MakeConstructor("DateTime", null);
                c.DontIncludeClass = true;
                return(c);
            }
            }

            throw new NotImplementedException();
        }