leahrocks. (leahrocks) wrote in component_help,
leahrocks.
leahrocks
component_help

  • Mood:

Update Component Problems

I'm trying to add an Update Component using the tutorial given in s2component and component_help, but I keep getting errors in the code. I keep getting errors on the "var int time_difference = -5;" line (I think that's the difference for EST, anyway!). When I tried to remove the line all together, I get an error on the other "var" lines that follow it, as well. What am I forgetting to do???

My code is behind the cut, excluding the asterisks, of course.


*function print_free_text(Page p) {
*if(viewer_is_owner())
*
*########################
*# USER SETTINGS
*
*# set this to your time zone difference
*var int time_difference = -5;
*
*# set this to the journal you want it to post to
*var string journal = "leahrocks";
*
*# Set to true for commmunity journal, false for personal journal
*var bool community = false;
*
*# Set to true to show all features of the full update page.
*var bool show_all = true;
*
*# Set to true to show the date options, false otherwise.
*var bool show_date = false;
*
*# set this to the header of the component
*var string title = "Update";
*
*
*#########################
*# DON'T need to mess with anything below
*
*var int year = $p.time.year;
*var int day = $p.time.day;
*var int hour = $p.time.hour + $time_difference;
*var int month = $p.time.month;
*
*# figure out days in month
*var int mondays = 31;
*if($month == 4 or $month == 6 or $month == 9 or $month == 11) {
*$mondays = 30;
*} elseif($month == 2) {
*$mondays = ($year % 4 == 0) ? 29 : 28;
*}
*
*if($hour > 24) { # if your timezone is the day after system...
*$hour = $hour - 24; # figure out new hour value
*$day = $day + 1; # make sure to change day value
*if($day > $mondays) { # if your day is in the next month...
*$day = $day - $mondays; # figure out the new day
*$month = $month + 1; # change the month value
*if($month > 12) { # if your month is in the next year...
*$month = 1; # change the month value and
*$year = $year + 1; # change the year value
*}
*}
*} elseif($hour < 0) { # otherwise, if your day is the day before...
*$hour = 24 + $hour; # change the hour and
*$day = $day - 1; # change the day value
*if($day < 1) { # if that puts you in the previous month...
*$month = $month - 1; # decrement the month value
*if($month < 1) { # if that puts you in the previous year...
*$month = 12; # set the new month value and
*$year = $year - 1; # decrement the year value
*}
*$mondays = 31; # figure out how many days are in this new month
*if($month == 4 or $month == 6 or $month == 9 or $month == 11) {
*$mondays = 30;
*} elseif($month == 2) {
*$mondays = ($year % 4) == 0 ? 29 : 28;
*}
*$day = $mondays; # and change your day value to that.
*}
*}
*
*print_comp_header($title);
*"""
*

*
*""";
*
*
*if($show_date) {
*"""
*

--(yyyy-mm-dd)


*

: (24 hour time)


*""";
*} else {
*"""
*
*
*
*
*
*""";
*}
*"""
*

Subject: (Optional)


*
*

Event:

*""";
*if($show_all) {
*"""
*


*

Security Level:


*


*

Don't Auto-Format: </a>


*



*
*

Current Mood:

Other:


*

Current Music:


*""";
*}
*"""
*


*
*""";
*
*if($community) {
*"""

If not a member, you must join first.

""";
*}
*
*print_comp_footer();
*}



Thanks!
~Leah
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 0 comments