Expand my Community achievements bar.

SOLVED

getTimeParting Plugin , Where to ?

Avatar

Level 8

Hello Adobe Community !

We are having a rough time with the time parting pluging on the DTM.

We have tryed putting it on a data element that would return the value, but this was not working everytile since the s object was sometimes unspecified.

Could someon tell us if we could put it on the Tool Custom Rules ?
Or do we have to put it in ALL of our rules ?

Documention tells to do it on the s.code, but our implementation has not ever tweeked the S code- We don't even know where to find it. We believe that since we use all the user interface of the DTM we don't have any s.code access !


Cheers !

1 Accepted Solution

Avatar

Correct answer by
Level 8

Hello,

So i had some help on this subject from the Adobe Customer Care , and since the doc on this is outdated , I will leave this to help any other person on this :

So, first of all, this neet to be implemented on the s code through the Tool config settings.

Tracker variable name : s
Code Type : Custom
s_code Storage Location : Manageds_code content :

var s = _satellite.getToolsByType('sc')[0].getS();

s.usePlugins=true

s.doPlugins=function(s) {

/* Plugin: getTimeParting 4.0 */

s.getTimeParting=function(z,h){var s=this,od=new Date("1/1/2000");if(od.getDay()!=6||od.getMonth()!=0)return"Data Not Available";else{var H,M,D,U,ds,de,tm,da=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],mo=["January","February","March","April","May","June","July","August","September","October","November","December"];d=new Date;z=z?z:0;z=parseFloat(z);h=h?h:"n";if(s._tpDST&&typeof s._tpDST[d.getFullYear()]!="undefined"){var dso=s._tpDST[d.getFullYear()].split(/,/);ds=new Date(dso[0]+

"/"+d.getFullYear());de=new Date(dso[1]+"/"+d.getFullYear());if(h=="n"&&d>ds&&d<de)z=z+1;else if(h=="s"&&(d>de||d<ds))z=z+1}d=d.getTime()+d.getTimezoneOffset()*6E4;d=new Date(d+36E5*z);H=d.getHours();M=d.getMinutes();M=M<10?"0"+M:M;U="AM";if(H>=12){U="PM";H=H-12}if(H==0)H=12;D=d.getDate()<10?"0"+d.getDate():d.getDate();tm=H+":"+M+" "+U;return"year="+d.getFullYear()+" | month="+mo[d.getMonth()]+" | date="+D+" | day="+da[d.getDay()]+" | time="+tm}};

/* Timeparting Daylight Savings Begin/End Dates */

s._tpDST={2015:"3/8,11/1",2016:"3/13,11/6",2017:"3/12,11/5",2018:"3/11,11/4",2019:"3/10,11/3",2020:"3/8,11/1",2021:"3/14,11/7",2022:"3/13,11/6",2023:"3/12,11/5",2024:"3/10,11/3",2025:"3/9,11/2",2026:"3/8,11/1",2027:"3/14,11/7",2028:"3/12,11/5",2029:"3/11,11/4",2030:"3/10,11/3"};

var gTP = s.prop74 = s.getTimeParting(5.5,"n");

var day = gTP.split("|")[3].split("=")[1] ;

var hour = gTP.split("|")[4].split("=")[1] ;

s.eVar74 = hour + "|" + day ;

}

In this exemple i Used slots prop74 and evar74 to store the timestamp !

Cheers !

View solution in original post

1 Reply

Avatar

Correct answer by
Level 8

Hello,

So i had some help on this subject from the Adobe Customer Care , and since the doc on this is outdated , I will leave this to help any other person on this :

So, first of all, this neet to be implemented on the s code through the Tool config settings.

Tracker variable name : s
Code Type : Custom
s_code Storage Location : Manageds_code content :

var s = _satellite.getToolsByType('sc')[0].getS();

s.usePlugins=true

s.doPlugins=function(s) {

/* Plugin: getTimeParting 4.0 */

s.getTimeParting=function(z,h){var s=this,od=new Date("1/1/2000");if(od.getDay()!=6||od.getMonth()!=0)return"Data Not Available";else{var H,M,D,U,ds,de,tm,da=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],mo=["January","February","March","April","May","June","July","August","September","October","November","December"];d=new Date;z=z?z:0;z=parseFloat(z);h=h?h:"n";if(s._tpDST&&typeof s._tpDST[d.getFullYear()]!="undefined"){var dso=s._tpDST[d.getFullYear()].split(/,/);ds=new Date(dso[0]+

"/"+d.getFullYear());de=new Date(dso[1]+"/"+d.getFullYear());if(h=="n"&&d>ds&&d<de)z=z+1;else if(h=="s"&&(d>de||d<ds))z=z+1}d=d.getTime()+d.getTimezoneOffset()*6E4;d=new Date(d+36E5*z);H=d.getHours();M=d.getMinutes();M=M<10?"0"+M:M;U="AM";if(H>=12){U="PM";H=H-12}if(H==0)H=12;D=d.getDate()<10?"0"+d.getDate():d.getDate();tm=H+":"+M+" "+U;return"year="+d.getFullYear()+" | month="+mo[d.getMonth()]+" | date="+D+" | day="+da[d.getDay()]+" | time="+tm}};

/* Timeparting Daylight Savings Begin/End Dates */

s._tpDST={2015:"3/8,11/1",2016:"3/13,11/6",2017:"3/12,11/5",2018:"3/11,11/4",2019:"3/10,11/3",2020:"3/8,11/1",2021:"3/14,11/7",2022:"3/13,11/6",2023:"3/12,11/5",2024:"3/10,11/3",2025:"3/9,11/2",2026:"3/8,11/1",2027:"3/14,11/7",2028:"3/12,11/5",2029:"3/11,11/4",2030:"3/10,11/3"};

var gTP = s.prop74 = s.getTimeParting(5.5,"n");

var day = gTP.split("|")[3].split("=")[1] ;

var hour = gTP.split("|")[4].split("=")[1] ;

s.eVar74 = hour + "|" + day ;

}

In this exemple i Used slots prop74 and evar74 to store the timestamp !

Cheers !