Class Index | File Index

## Classes

- _global_
- Array
- links.StepDate
- links.Timeline

# Class links.StepDate

StepDate The class StepDate is an iterator for dates. You provide a start date and an end date. The class itself determines the best scale (step size) based on the provided start Date, end Date, and minimumStep. If minimumStep is provided, the step size is chosen as close as possible to the minimumStep but larger than minimumStep. If minimumStep is not provided, the scale is set to 1 DAY. The minimumStep should correspond with the onscreen size of about 6 characters Alternatively, you can set a scale by hand. After creation, you can initialize the class by executing start(). Then you can iterate from the start date to the end date via next(). You can check if the end date is reached with the function end(). After each step, you can retrieve the current date via get(). The class step has scales ranging from milliseconds, seconds, minutes, hours, days, to years. Version: 0.9
Defined in: timeline.js.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| links.StepDate(start, end, minimumStep)

Method Summary
Method Attributes | Method Name and Description
--- | ---
| addZeros(value, len) Add leading zeros to the given value to match the desired length.
| end() Check if the end date is reached
| getCurrent() Get the current datetime
| getLabelMajor(optional) Returns formatted text for the major axislabel, depending on the current date and the scale.
| getLabelMinor() Returns formatted text for the minor axislabel, depending on the current date and the scale.
| isMajor() Check if the current step is a major step (for example when the step is DAY, a major step is each first day of the MONTH)
| next() Do the next step
| roundToMinor() Round the current date to the first minor date value This must be executed once when the current date is set to start Date
| setAutoScale(enable) Enable or disable autoscaling
| setMinimumStep(minimumStep) Automatically determine the scale that bests fits the provided minimum step
| setRange(start, end, minimumStep) Set a new range If minimumStep is provided, the step size is chosen as close as possible to the minimumStep but larger than minimumStep.
| setScale(newScale, newStep) Set a custom scale.
| snap(date) Snap a date to a rounded value.
| start() Set the step iterator to the start date.

Class Detail
links.StepDate(start, end, minimumStep)

Parameters:
{Date} start
  The start date, for example new Date(2010, 9, 21) or new Date(2010, 9,21,23,45,00)
{Date} end
  The end date
{int} minimumStep
  Optional. Minimum step size in milliseconds

Method Detail
{string} addZeros(value, len)
Add leading zeros to the given value to match the desired length. For example addZeros(123, 5) returns "00123"

Parameters:
{int} value
  A value
{int} len
  Desired final length

Returns:
  {string} value with leading zeros

{boolean} end()
Check if the end date is reached

Returns:
  {boolean} true if the current date has passed the end date

{Date} getCurrent()
Get the current datetime

Returns:
  {Date} current The current date

{string} getLabelMajor(optional)
Returns formatted text for the major axislabel, depending on the current date and the scale. For example when scale is MINUTE, the major scale is hours, and the hour will be formatted as "hh".

Parameters:
{Date} optional
  custom date. if not provided, current date is taken

Returns:
  {string} major axislabel

{string} getLabelMinor()
Returns formatted text for the minor axislabel, depending on the current date and the scale. For example when scale is MINUTE, the current time is formatted as "hh::mm".

Returns:
  {string} minor axislabel

isMajor()
Check if the current step is a major step (for example when the step is DAY, a major step is each first day of the MONTH)

Returns:
  true if current date is major, else false.

next()
Do the next step

roundToMinor()
Round the current date to the first minor date value This must be executed once when the current date is set to start Date

setAutoScale(enable)
Enable or disable autoscaling

Parameters:
{boolean} enable
  If true, autoascaling is set true

setMinimumStep(minimumStep)
Automatically determine the scale that bests fits the provided minimum step

Parameters:
{int} minimumStep
  The minimum step size in milliseconds

setRange(start, end, minimumStep)
Set a new range If minimumStep is provided, the step size is chosen as close as possible to the minimumStep but larger than minimumStep. If minimumStep is not provided, the scale is set to 1 DAY. The minimumStep should correspond with the onscreen size of about 6 characters

Parameters:
{Date} start
  The start date and time.
{Date} end
  The end date and time.
{int} minimumStep
  Optional. Minimum step size in milliseconds

setScale(newScale, newStep)
Set a custom scale. Autoscaling will be disabled. For example setScale(SCALE.MINUTES, 5) will result in minor steps of 5 minutes, and major steps of an hour.

Parameters:
{Step.SCALE} newScale
  A scale. Choose from SCALE.MILLISECOND, SCALE.SECOND, SCALE.MINUTE, SCALE.HOUR, SCALE.DAY, SCALE.MONTH, SCALE.YEAR.
{int} newStep
  A step size, by default 1. Choose for example 1, 2, 5, or 10.

snap(date)
Snap a date to a rounded value. The snap intervals are dependent on the current scale and step.

Parameters:
{Date} date
  the date to be snapped

start()
Set the step iterator to the start date.

Documentation generated by JsDoc Toolkit 2.3.2 on Wed Mar 30 2011 11:45:24 GMT+0200 (CEST)