~budgester/irm/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
<?php
/******************************************************************************************************
/  Class SDTO - Simple DateTime Object
/               A simple way to handle times and dates and to convert between
/               System and SQL Formats
/
/  (C) 2001-2004 Christian Hansel, CVH, chris@cpi-service.com
/
/  Distributed under GPL, may be distributed, modified and utilized if Copyright
/  notice is maintained and manual is provided and author is notified of modifications
/
/  Please support our development by sending remarks or comments or suggestions
/
/********************************************************************************************************/

class SimpleDateTimeObject {
     var $basetime;            // @private - holds UniX Timestamp
     var $calctime;            // @private - holds UniX Timestamp Calculations
     var $stdParamDateList;     // @private - holds StandardParameters for Dropdown-lists
     var $stdParamAdd;        // @private - holds StandardParameters for Adding/Substracting Periods

    /* Constructor */
    function SimpleDateTimeObject ($timestamp = -1) {
        $this->basetime = ($timestamp == -1) ? mktime() : $timestamp;
        $this->calctime = $this->basetime;
        $this->stdParamDateList = array( "start"     => 0,
                                         "run"         => 5,
                                         "steps"     => 1,
                                         "running"    =>"days",
                                         "format"    =>"d.M.Y H:i",
                                         "keyformat" => "" ,
                                         "style" => "");

        $this->stdParamAdd         = array( "years"=>0,
                                         "months"=>0,
                                         "days"=>0,
                                         "hours"=>0,
                                         "minutes"=>0,
                                         "seconds"=>0);
    }



    /****************************************************************************************************
    /   @public Time2Array -
    /                  Helper Function which Transforms a Time-String
    /                in SQL Format into an Array of Periods
    /    Parameters    $timestring - e.g. "-01:00:00)
    /
    /********************************************************************************************************/


    function Time2Array($timestring) {
        $timestring = preg_replace("#\s#","",$timestring);
        $timestring = preg_replace("#\:#","",$timestring);
        $timestring = preg_replace("#\.#","",$timestring);
        $timestring = preg_replace("#\-#","",$timestring);
        $timestring = preg_replace("#\/#","",$timestring);
        $fac = ("-" == substr($timestring,0,1)) ? -1 : 1;

        $timestring = ("-" == substr($timestring,0,1) || "+" == substr($timestring,0,1)) ? substr($timestring,1,strlen($timestring)-1) : $timestring;

        $array['hours']     = $fac * substr($timestring, 0,2);
        $array['minutes']     = $fac * substr($timestring, 2,2) ;
        $array['seconds']     = (4 < strlen($timestring)) ? $fac * substr($timestring, 4,2) : 0;
        return $array;
    }


    /****************************************************************************************************
    /   @public DateTime2Array -
    /                  Helper Function which Transforms a DateTime-String
    /                in SQL Format into an Array of Periods
    /    Parameters    $timestring - e.g. "12.01.2004 23:00:00)
    /
    /********************************************************************************************************/
    function DateTime2Array($timestring) {
        $timestring = preg_replace("#\s#","",$timestring);
        $timestring = preg_replace("#\:#","",$timestring);
        $timestring = preg_replace("#\.#","",$timestring);
        $timestring = preg_replace("#\/#","",$timestring);
        $timestring = preg_replace("#\-#","",$timestring);
        $fac = ("-" == substr($timestring,0,1)) ? -1 : 1;
        $timestring = ("-" == substr($timestring,0,1)) ? substr($timestring,1,strlen($timestring)-1) : $timestring;

        $array['years']     = (6==strlen($timestamp)) ? $fac * substr($timestamp,0,2): $fac * substr($timestamp,0,4);
        $array['months']     = (6==strlen($timestamp)) ? $fac * substr($timestamp,2,2): $fac * substr($timestamp,4,2);
        $array['days']        = (6==strlen($timestamp)) ? $fac * substr($timestamp,4,2): $fac * substr($timestamp,6,2);
        $array['hours']     = (12 > strlen($timestamp)) ? 0 : $fac * substr($timestamp, 8,2);
        $array['minutes']     = (12 > strlen($timestamp)) ? 0 : $fac * substr($timestamp, 10,2);
        $array['seconds']     = (14 > strlen($timestamp)) ? 0 : $fac * substr($timestamp, 12,2);
        return $array;
    }



    /****************************************************************************************************
    /   @public add -
    /                  Adds a Period to the BaseTime of the Object
    /                Returns a Unix Timestamp
    /    Parameters    $param [Array]- e.g.array("days"=>2, "months"=> 1, "hours"=>4)
    /                optional $overwrite [Bool] = true - If true the BaseTime of the
    /                                                    Object will be overwritten with
    /                                                    or adjusted to the calculated result
    /
    /********************************************************************************************************/
    function add($param = array(), $overwrite = true) {
        $base_day = date ("d",$this->basetime);
        $base_month = date ("m",$this->basetime);
        $base_year = date ("Y",$this->basetime);
        $base_hour = date ("H",$this->basetime);
        $base_minute = date ("i",$this->basetime);
        $base_second = date ("s",$this->basetime);

        $hours = (isset($param['hours']) && ! empty($param['hours'])) ? $param['hours'] : $this->stdParamAdd['hours'];
        $minutes = (isset($param['minutes']) && ! empty($param['minutes'])) ? $param['minutes'] : $this->stdParamAdd['minutes'];
        $seconds = (isset($param['seconds']) && ! empty($param['seconds'])) ? $param['seconds'] : $this->stdParamAdd['seconds'];
        $days = (isset($param['days']) && ! empty($param['days'])) ? $param['days'] : $this->stdParamAdd['days'];
        $months = (isset($param['months']) && ! empty($param['months'])) ? $param['months'] : $this->stdParamAdd['months'];
        $years = (isset($param['years']) && ! empty($param['years'])) ? $param['years'] : $this->stdParamAdd['years'];


        $this->calctime = mktime ( $base_hour      +     $hours,
                        $base_minute +     $minutes,
                        $base_second +     $seconds,
                        $base_month  +     $months,
                        $base_day      +     $days,
                        $base_year      +     $years);
        if ($overwrite) {
            $this->basetime = $this->calctime;
        }




        return $this->calctime;

    }


    /****************************************************************************************************
    /   @public sub -
    /                  Subtracts a Period from the BaseTime of the Object
    /                Returns a Unix Timestamp
    /    Parameters    $param [Array]- e.g.array("days"=>2, "months"=> 1, "hours"=>4)
    /                optional $overwrite [Bool] = true - If true the BaseTime of the
    /                                                    Object will be overwritten with
    /                                                    or adjusted to the calculated result
    /
    /********************************************************************************************************/
    function sub($param = array(), $overwrite = true) {
        $base_day = date ("d",$this->basetime);
        $base_month = date ("m",$this->basetime);
        $base_year = date ("Y",$this->basetime);
        $base_hour = date ("H",$this->basetime);
        $base_minute = date ("i",$this->basetime);
        $base_second = date ("s",$this->basetime);

        $hours = (isset($param['hours']) && ! empty($param['hours'])) ? $param['hours'] : $this->stdParamAdd['hours'];
        $minutes = (isset($param['minutes']) && ! empty($param['minutes'])) ? $param['minutes'] : $this->stdParamAdd['minutes'];
        $seconds = (isset($param['seconds']) && ! empty($param['seconds'])) ? $param['seconds'] : $this->stdParamAdd['seconds'];
        $days = (isset($param['days']) && ! empty($param['days'])) ? $param['days'] : $this->stdParamAdd['days'];
        $months = (isset($param['months']) && ! empty($param['months'])) ? $param['months'] : $this->stdParamAdd['months'];
        $years = (isset($param['years']) && ! empty($param['years'])) ? $param['years'] : $this->stdParamAdd['years'];


        $this->calctime = mktime ( $base_hour     -     $hours,
                        $base_minute -     $minutes,
                        $base_second -     $seconds,
                        $base_month  -     $months,
                        $base_day      -     $days,
                        $base_year      -     $years);
        if ($overwrite) {
            $this->basetime = $this->calctime;
        }




        return $this->calctime;

    }



    /****************************************************************************************************
    /   @public  diff_MySQL -
    /                  Calculates the Difference between a MYSQL Timestamp
    /                and the Objects Basetime which is useful for SQL commands
    /                like "SELECT DAT_ADD(mydate, INTERVAL '10 02' DAY_HOUR)
    /                or to be used in PHP/HTML : print "The time you have to do this job is ".$result['days'];
    /            returns an array like Array {     "years" => 1 ,
    /                                            "weeks" => 5 ,
    /                                            "days"  => 3 ,
    /                                            "hours" => 0,
    /                                            "minutes"  => 35 ,
    /                                            "days"  => 0 }
    /            when the Parameter $timestring lies 1 year and 5 weeks and 3 days and 35 minutes after
    /            the Basetime of the Object                                        }
    /    Parameters    $timestring - A MysQL Dat/DateTime String : e.g. "20040711132712"
    /                 $allow_negative    -  if true negative Differences will be returned as such
    /                                    otherwise differences are always positive
    /
    /********************************************************************************************************/

    function diff_MySQL($timestring, $allow_negative = false) {
        $basetime = $this->basetime;        // 2BRemembered
        $target = $this->setMySQLDateTime($timestring);
        if ($target > $basetime) {
            $diff = $target - $basetime ;
            $fac = 1;
        } else {
            $diff = $basetime-$target;
            $fac = ($allow_negative)? -1 : 1;
        }
        $diffarr['years'] = $fac * $this->extract_from_seconds($diff,"years");
        $diffarr['weeks'] =  $fac * $this->extract_from_seconds($diff,"weeks");
        $diffarr['days'] =  $fac * $this->extract_from_seconds($diff,"days");
        $diffarr['hours'] =  $fac * $this->extract_from_seconds($diff,"hours");
        $diffarr['minutes'] =  $fac * $this->extract_from_seconds($diff,"minutes");
        $diffarr['seconds'] =  $fac * $this->extract_from_seconds($diff,"seconds");
        $this->basetime = $basetime;

        return $diffarr;
    }


    /****************************************************************************************************
    /   @private / public   extract_from_seconds -
    /                  extracts full years / days / weeks / hours / or minutes from a Unix Timestamp a
    /                any period given seconds
    /            returns an integer of the time unit provided as parameter 2 (e.g. 'hours')
    /    Parameters    $seconds !!!ByRef!!!     - An integer of seconds
    /                $what (String)            - What shall be extracted ("hours"/"minutes"/"days"/"weeks"/"years")
    /
    /
    /********************************************************************************************************/

    function extract_from_seconds(&$seconds,$what) {
    switch ($what) {
        case "minutes":    case "minutes": case "minutes": case "i":
            $value = bcdiv($seconds,60);
            $seconds =  bcmod($seconds,60);
            break;
        case "hours": case "H": case "h": case "hour":
            $value = bcdiv($seconds,3600);
            $seconds =  bcmod($seconds,3600);
            break;
        case "days": case "D": case "d": case "day":
            $value         = bcdiv($seconds,3600*24);
            $seconds     = bcmod($seconds,3600*24);
            break;
        case "weeks": case "W": case "w": case "week":
            $value         = bcdiv($seconds,3600*24*7);
            $seconds     = bcmod($seconds,3600*24*7);
            break;
        case "years": case "year": case "y": case "Y":
            $value         = bcdiv($seconds,3600*24*365);
            $seconds     = bcmod($seconds,3600*24*365);
            break;
        default:
            $value = $seconds;
    }
    return $value;

    }



    /****************************************************************************************************
    /   @private / public   reset -
    /                  resets the Object's basetime to the current Systemtime
    /
    /
    /********************************************************************************************************/

    function reset() {
        $this->DateTimeObject(mktime());
    }



    /****************************************************************************************************
    /   @public   setMySQLDateTime($timestamp) -
    /                  Sets the Object's base time to the time provided by Timestring
    /                return Unix timestamp equivilant
    /    Parameters : $timestring =     String of MySQL DateTime (e.g ("20010911091200") or "2001-09-11 09:12:00")
    /
    /
    /********************************************************************************************************/

    function setMySQLDateTime($timestring) {
        $timestring .="";
        $timestring = preg_replace("#\s#","",$timestring);
        $timestring = preg_replace("#\:#","",$timestring);
        $timestring = preg_replace("#\.#","",$timestring);
        $timestring = preg_replace("#\-#","",$timestring);
        $timestring = preg_replace("#\/#","",$timestring);
        $year     = (6==strlen($timestring)) ? substr($timestring,0,2): substr($timestring,0,4);
        $month     = (6==strlen($timestring)) ? substr($timestring,2,2): substr($timestring,4,2);
        $day     = (6==strlen($timestring)) ? substr($timestring,4,2): substr($timestring,6,2);
        $hour     = (12 > strlen($timestring)) ? 0 : substr($timestring, 8,2);
        $minute = (12 > strlen($timestring)) ? 0 : substr($timestring, 10,2);
        $second = (14 > strlen($timestring)) ? 0 : substr($timestring, 12,2);

        $this->SimpleDateTimeObject(mktime($hour,$minute,$second,$month, $day,$year));
        return $this->getTimestamp();
    }



    /****************************************************************************************************
    /   @public   getMySQLDateTime() -
    /                  Returns the Object's base time in preset MySQLFormat "YmdHis"
    /
    /
    /
    /********************************************************************************************************/
    function getMySQLDateTime(){
        return date("YmdHis",$this->basetime);
    }


    /****************************************************************************************************
    /    @public   getTimestamp() -
    /                  Returns the Object's base time as Unix TimeStamp
    /
    /
    /
    /********************************************************************************************************/
    function getTimestamp() {
        return $this->basetime;
    }


    /****************************************************************************************************
    /   @public   day() -
    /                  Returns the Day of the Object's base time
    /    Paramters optional $format - specify the format of the returned value
    /                                 according to the allowed Format Strings of
    /                                 PHP 's own date command
    /             optional $timestamp - specify a time of which a part shall be returned
    /                                   if not specified the Objects BaseTime will be used
    /
    /
    /********************************************************************************************************/

    function day( $format = "d", $timestamp = 0) {
        if ($timestamp == 0) { return date ($format,$this->basetime);
        } else {return date ($format,$timestamp);}
    }
    /****************************************************************************************************
    /   @public   month() -
    /                  Returns the Month of the Object's base time
    /    Paramters optional $format - specify the format of the returned value
    /                                 according to the allowed Format Strings of
    /                                 PHP 's own date command
    /             optional $timestamp - specify a time of which a part shall be returned
    /                                   if not specified the Objects BaseTime will be used
    /
    /
    /********************************************************************************************************/
    function month ( $format = "m", $timestamp = 0) {
        if ($timestamp == 0) { return date ($format,$this->basetime);
        } else {return date ($format,$timestamp);}
    }
    /****************************************************************************************************
    /   @public  year() -
    /                  Returns the Year of the Object's base time
    /    Paramters optional $format - specify the format of the returned value
    /                                 according to the allowed Format Strings of
    /                                 PHP 's own date command
    /             optional $timestamp - specify a time of which a part shall be returned
    /                                   if not specified the Objects BaseTime will be used
    /
    /
    /********************************************************************************************************/
    function year ( $format = "Y", $timestamp = 0) {
        if ($timestamp == 0) { return date ($format,$this->basetime);
        } else {return date ($format,$timestamp);}
    }
    /****************************************************************************************************
    /   @public  hour() -
    /                  Returns the hour of the Object's base time
    /    Paramters optional $format - specify the format of the returned value
    /                                 according to the allowed Format Strings of
    /                                 PHP 's own date command
    /             optional $timestamp - specify a time of which a part shall be returned
    /                                   if not specified the Objects BaseTime will be used
    /
    /
    /********************************************************************************************************/
    function hour ( $format = "H", $timestamp = 0) {
        if ($timestamp == 0) { return date ($format,$this->basetime);
        } else {return date ($format,$timestamp);}
    }
    /****************************************************************************************************
    /   @public  minute() -
    /                  Returns the Minutes of the Object's base time
    /    Paramters optional $format - specify the format of the returned value
    /                                 according to the allowed Format Strings of
    /                                 PHP 's own date command
    /             optional $timestamp - specify a time of which a part shall be returned
    /                                   if not specified the Objects BaseTime will be used
    /
    /
    /********************************************************************************************************/
    function minute ( $format = "i", $timestamp = 0) {
        if ($timestamp == 0) { return date ($format,$this->basetime);
        } else {return date ($format,$timestamp);}
    }
    /****************************************************************************************************
    /   @public  second() -
    /                  Returns the Seconds of the Object's base time
    /    Paramters optional $format - specify the format of the returned value
    /                                 according to the allowed Format Strings of
    /                                 PHP 's own date command
    /             optional $timestamp - specify a time of which a part shall be returned
    /                                   if not specified the Objects BaseTime will be used
    /
    /
    /********************************************************************************************************/
    function second ( $format = "s", $timestamp = 0) {
        if ($timestamp == 0) { return date ($format,$this->basetime);
        } else {return date ($format,$timestamp);}
    }
    /****************************************************************************************************
    /  @public  getString -
    /                  Returns the Formated Time of the Object's base time
    /    Paramters optional $format - specify the format of the returned value
    /                                 according to the allowed Format Strings of
    /                                 PHP 's own date command
    /             optional $timestamp - specify a time of which a part shall be returned
    /                                   if not specified the Objects BaseTime will be used
    /
    /
    /********************************************************************************************************/

    function getString ( $format = "M, dS Y h:i a", $timestamp = 0) {
        if ($timestamp == 0) { return date ($format,$this->basetime);
        } else {return date ($format,$timestamp);}
    }



    /****************************************************************************************************
    / @public   dropdown
    /                   - returns a string containing a HTML DropDown Field (SELECT) based on the current basetime
    /           Parameters :
    /                   $name - Name of the HTML-Select Tag
    /                   optional $param - Array of Paramaters configuring the Select Field
                                    ['formatshow']        -     Specify the way the entries will be showed
    /                               ['format']          -   Specify the kind of Field to be produced (months / years / days ..
                                                            What will be run?
                                    ['start']           -   Specify a start value
                                                            From where will be run?
    /                               ['run']             -   Specify the number of entries to be produced
    /                                                       How far will be run?/
    /                               ['style']           -   Specify a CSS - Class to be used
    /                               ['selectsize']      -   Specify the Size of the Select Tag ( 1 Row or multirow)
    /                               ['selecteddate']    -   preselected Date
    /
    /***************************************************************************************************/
    function dropdown ($name, $param=array()) {
        $start = (isset($param['start']) && ! empty($param['start'])) ? $param['start'] : $this->stdParamAdd['start'];
        $run = (isset($param['run']) && ! empty($param['run'])) ? $param['run'] : $this->stdParamAdd['run'];
        $format = (isset($param['format']) && ! empty($param['format'])) ? $param['format'] : "d";
        $style = (isset($param['style']) && ! empty($param['style'])) ? $param['style'] : "";
        $selectsize  = (isset($param['selectsize']) && ! empty($param['selectsize'])) ? $param['selectsize'] : 1;

        $selecteddate = (isset($param['selecteddate']) && ! empty($param['selecteddate'])) ? $param['selecteddate'] : $this->basetime;

        $base_day = date ("d",$this->basetime);
        $base_month = date ("m",$this->basetime);
        $base_year = date ("Y",$this->basetime);
        $base_hour = date ("H",$this->basetime);
        $base_minute = date ("i",$this->basetime);
        $base_second = date ("s",$this->basetime);


        switch ($format) {
            case "months": case "month": case "m":
                $frm = "m"; $field = &$base_month; $base_day=1;  // As there are months which don't have 29th,30th,31st
                break;
            case "years": case "year": case "y": $base_day=1;  // As there are months which don't have 29th,30th,31st
                $frm = "Y"; $field = &$base_year;
                break;
            case "hours": case "hour": case "h":
                $frm = "H"; $field = &$base_hour;
                break;
            case "minutes": case "minute": case "i":
                $frm = "i"; $field = &$base_minute;
                break;
            case "seconds": case "second": case "s":
                $frm = "s"; $field = &$base_second;
                break;
            case "days": case "day": case "d": default:
                $frm = "d"; $field = &$base_day;
                break;

        }

        $formatshow = (isset($param['formatshow']) && ! empty($param['formatshow'])) ? $param['formatshow'] : $frm;

        $start = date($frm, $this->basetime) + $start;
        $selected = date($frm, $selecteddate);

        for($field=$start; $field<=$start+$run; $field++)
        {
             $key = date ($frm,mktime ( $base_hour, $base_minute, $base_second, $base_month, $base_day, $base_year));
            $value = date ($formatshow,mktime ( $base_hour, $base_minute, $base_second, $base_month, $base_day, $base_year));
            $outputString .= ($key == $selected) ? '  <option value="'.$key.'" selected="selected">'.$value."</option>\n" : '  <option value="'.$key.'">'.$value."</option>\n";
        }
        return  "<select name=\"".$name."\" class=\"$style\" size=\"$selectsize\">\n".$outputString."</select>\n";


    }
    /****************************************************************************************************
    / @public   datelist
    /                   - returns a string containing a HTML DropDown Field (SELECT) based on the current basetime
    /           Parameters :
    /                   $name - Name of the HTML-Select Tag
    /                   optional $param - Array of Paramaters configuring the Select Field
    /                               ['format']          -   Specify the format of the Labels in the Selectbox
                                    ['keyformat']       -   Specify the format of the value in the option tags
                                    ['running']         -   Specify iteration / What will be run ? (e.g. "hours", "years")
                                    ['start']           -   Specify a start value
                                                            From where will be run?
    /                               ['run']             -   Specify the number of entries to be produced
    /                                                       How far will be run?/
                                    ['steps']           -   Specify the distance between the entries in X format
    /                               ['style']           -   Specify a CSS - Class to be used
    /                               ['selectsize']      -   Specify the Size of the Select Tag ( 1 Row or multirow)
    /                               ['selecteddate']    -   preselected Date
    /
    /***************************************************************************************************/
    function datelist (    $name, $param = array()) {
        $base_day = date ("d",$this->basetime);
        $base_month = date ("m",$this->basetime);
        $base_year = date ("Y",$this->basetime);
        $base_hour = date ("H",$this->basetime);
        $base_minute = date ("i",$this->basetime);
        $base_second = date ("s",$this->basetime);

        $start = (isset($param['start']) && ! empty($param['start'])) ? $param['start'] : $this->stdParamAdd['start'];
        $run = (isset($param['run']) && ! empty($param['run'])) ? $param['run'] : $this->stdParamAdd['run'];
        $steps = (isset($param['steps']) && ! empty($param['steps'])) ? $param['steps'] : $this->stdParamAdd['steps'];
        $running = (isset($param['running']) && ! empty($param['running'])) ? $param['running'] : $this->stdParamAdd['running'];
        $format = (isset($param['format']) && ! empty($param['format'])) ? $param['format'] : $this->stdParamAdd['format'];
        $keyformat = (isset($param['keyformat']) && ! empty($param['keyformat'])) ? $param['keyformat'] : $this->stdParamAdd['keyformat'];
        $style = (isset($param['style']) && ! empty($param['style'])) ? $param['style'] : "";
        $selectsize  = (isset($param['selectsize']) && ! empty($param['selectsize'])) ? $param['selectsize'] : 1;
        $selecteddate = (isset($param['selecteddate']) && ! empty($param['selecteddate'])) ? $param['selecteddate'] : $this->basetime;

        $steps = ($steps<1) ? 1 : $steps;
        switch ($running) {
            case "days": case "day": case "d":
                $field = &$base_day; $frm = "d";
                break;
            case "months": case "month": case "m":
                $field = &$base_month; $frm = "m";
                break;
            case "years": case "year": case "y":
                $field = &$base_year; $frm = "Y";
                break;
            case "hours": case "hour": case "h":
                $field = &$base_hour; $frm = "H";
                break;
            case "minutes": case "minute": case "i":
                $field = &$base_minute; $frm = "i";
                break;
            case "seconds": case "second": case "s":
                $field = &$base_second; $frm = "s";
                break;
        }
        $start = date($frm, $this->basetime) + $start;
        $selected = date($keyformat, $selecteddate);

        for($field=$start; $field<=$start+$run; $field=$field+$steps)
        {
            if ("" == $keyformat) {
                $key = mktime ( $base_hour, $base_minute, $base_second, $base_month, $base_day, $base_year);
            } else { $key = date($keyformat,mktime ( $base_hour, $base_minute, $base_second, $base_month, $base_day, $base_year));     }
            $value = date($format,mktime ( $base_hour, $base_minute, $base_second, $base_month, $base_day, $base_year));

            $outputString .= ($key==$selected)? '  <option value="'.$key.'" selected="selected">'.$value."</option>\n" : '  <option value="'.$key.'">'.$value."</option>\n";

        }
        return  "<select name=\"".$name."\" class=\"$style\" size=\"$selectsize\">\n".$outputString."</select>\n";


    }
}

if (! function_exists('bcdiv')) {
    function bcdiv($divident, $divisor)  // Ganzzahldivision - ERsatz für bcdiv
    {
        return floor($divident/$divisor);
    }
}
if (! function_exists('bcmod')) {
    function bcmod($divident, $divisor) // Ganzzahldivisionsmodulo - Eratz für bcmod
    {
        return $divident - ($divisor*bcdiv($divident,$divisor));
    }
}
?>