Created
August 3, 2015 17:47
-
-
Save gmcdev/1994c42c88d62ecffadb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** This method will make a list of dates available to the Static Generator application which will then make | |
| snapsnots of the ad's endframe on each of these dates. If only one date is submitted, Static Generator will | |
| assume the same intervals that <DateUtils>.selectMessagingForDate uses. | |
| $_dates - list of dates that snapshots will be taken on | |
| $_tzDesignation - the timezone in which this schedule expresses its dates */ | |
| public function setStaticSchedule( $_dates:Array, $_tzDesignation:Object=null, $_dateLabels:Array=null ):void { | |
| Trace.out( this, 'setStaticSchedule()' ); | |
| if( !$_dateLabels ) $_dateLabels = []; | |
| if( $_dates.length == 1 ) { | |
| Trace.out( this, ' - single tune-in date: generating dates for messaging states...' ); | |
| var _eventDayStart:Date = new Date( $_dates[0] ); | |
| _eventDayStart.time -= ( | |
| ( $_dates[0].hours * DateUtils.MS_PER_HOUR ) + | |
| ( $_dates[0].minutes * DateUtils.MS_PER_MINUTE ) + | |
| ( $_dates[0].seconds * 1000 ) - | |
| ( DateSettings.newDayStartsAt * DateUtils.MS_PER_MINUTE ) | |
| ); | |
| // week before | |
| var _weekBefore:Date = new Date( _eventDayStart ); | |
| _weekBefore.time -= DateUtils.MS_PER_WEEK; | |
| // week of | |
| var _weekOf:Date = new Date( _eventDayStart ); | |
| _weekOf.time -= ( DateUtils.MS_PER_WEEK - ( DateUtils.MS_PER_DAY * 2 )); | |
| // day before | |
| var _dayBefore:Date = new Date( _eventDayStart ); | |
| _dayBefore.time -= ( DateUtils.MS_PER_HOUR * 6 ); | |
| // day of | |
| var _dayOf:Date = new Date( _eventDayStart ); | |
| _dayOf.time += ( DateUtils.MS_PER_HOUR * 6 ); | |
| // live | |
| var _live:Date = new Date( $_dates[0] ); | |
| _live.time += ( DateUtils.MS_PER_MINUTE * 15 ); | |
| $_dates = [ | |
| _weekBefore, _weekOf, _dayBefore, _dayOf, _live | |
| ]; | |
| $_dateLabels = ['week_before', 'week_of', 'day_before', 'day_of', 'live']; | |
| } | |
| else { | |
| Trace.out( this, ' - date range' ); | |
| var _dateLabels:Array = []; | |
| for each( var _date:Date in $_dates ) { | |
| _date.time += ( DateUtils.MS_PER_MINUTE * 15 ); | |
| var _year = StringUtils.toDigits( _date.fullYear, 4 ); | |
| var _month = StringUtils.toDigits( _date.month+1, 2 ); | |
| var _day = StringUtils.toDigits( _date.date, 2 ); | |
| var _time:String = StringUtils.toDigits( _date.hours, 2 ) + StringUtils.toDigits( _date.minutes, 2 ); | |
| _dateLabels.push( _year + _month + _day + '_' + _time ); | |
| } | |
| if( $_dateLabels.length != $_dates.length ) | |
| $_dateLabels = _dateLabels; | |
| else { | |
| for each( var _dateLabel:String in $_dateLabels ) { | |
| _dateLabel = _dateLabel.replace( /\'|\"|\-|\s|\/|\\|/g, '_' ); | |
| } | |
| } | |
| } | |
| externalParams.staticGenerator = { | |
| dates: $_dates, | |
| dateLabels: $_dateLabels, | |
| tzDesignation: $_tzDesignation || DateUtils.TZ_LOCAL | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment