Jump to content

js function to PHP


AviNahum

Recommended Posts

i trying to rewrite a whole js file into php code and i have some issues with a few functions

 

Date.prototype.ConvertToUTCDate = function() {
var utcDate = new Date(this.getUTCFullYear(), this.getUTCMonth(), this.getUTCDate(), this.getUTCHours() + WinnerConsts.TIME_ZONE, this.getUTCMinutes(), this.getUTCSeconds());
return utcDate;
}
 parseLineDates: function(lgObj) {
  lgObj.FullDate = parseInner(lgObj.FullDate);
  lgObj.Day = parseInner(lgObj.Day);
  lgObj.Time = parseInner(lgObj.Time);
  function parseInner(d) {

    d = d.substr(6);
			 d = parseInt(d);
			 d = (new Date(d)).ConvertToUTCDate();
   return d;
  }
 }
  function fromUTCArray(A) {
   var D = new Date;
   while (A.length < 7) A.push(0);
   var T = A.splice(3, A.length);
   D.setUTCFullYear.apply(D, A);
   D.setUTCHours.apply(D, T);
   return D;
  }
  // ReParsing from Json Cloning.
  function parseLineDates(lgObj) {
   lgObj.FullDate = parseInner(lgObj.FullDate);
   lgObj.Day = parseInner(lgObj.Day);
   lgObj.Time = parseInner(lgObj.Time);
   function parseInner(d) {
 //return new Date(Date.parse(d));
 return parseTest(d);
   }
  }
  function parseTest(s) {
   var D, M = [],
 hm, min = 0,
 d2, Rx = /([\d:]+)(\.\d+)?(Z|(([+\-])(\d\d)\d\d))?)?$/;
   D = s.substring(0, 10).split('-');
   if (s.length > 11) {
 M = s.substring(11).match(Rx) || [];
 if (M[1]) D = D.concat(M[1].split(':'));
 if (M[2]) D.push(Math.round(M[2] * 1000)); // msec
   }
   for (var i = 0, L = D.length; i < L; i++) {
 D[i] = parseInt(D[i], 10);
   }
   D[1] -= 1;
   while (D.length < 6) D.push(0);
   if (M[4]) {
 min = parseInt(M[6]) * 60 + parseInt(M[7], 10); // timezone not UTC
 if (M[5] == '+') min *= -1;
   }
   try {
 d2 = fromUTCArray(D);
 if (min) d2.setUTCMinutes(d2.getUTCMinutes() + min);
   } catch (er) {
 // bad input
   }
   return d2;
  }

 

i dont have any idea how to convert this into PHP and would like to get some help...

Thank in advanced and sorry for poor english...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.