Lasso Soft Inc. > Home

[ date->weekOfYear ]

Method

[Date->WeekOfYear] is an accessor for getting or setting the weekofyear field for a date object.

Getting uses no parameters and returns the weekofyear as an integer from 1 to 53 for a specified Lasso date/time object. Note that either the first or last weekofyear of the year may fall partly in the previous or next year. In this case the first days of the year may be part of weekofyear 52 or weekofyear 53, or the last days of the year may be part of weekofyear 1. WeekOfYear in Lasso starts on Sunday by default.

Setting requires an integer parameter, and supports the =, += and -= operators. Setting modifies the date object in-place, but does not return a value.

[Date->WeekOfYear] is a synonym for [Date->Week].

  • Syntax
Date Object->weekofyear
Date Object->weekofyear=Integer
Date Object->weekofyear+=Integer
Date Object->weekofyear-=Integer
Examples
  • Beginner

To get or set the weekofyear field of a date object:

Use the [Date->WeekOfYear] method. The following example uses a single date object, then gets the weekofyear and returns its value.

Next we set the weekofyear field to a new value using the = operator, then set it again by adding 1 to the weekofyear using the += operator, and set it once more by subtracting 1 from the weekofyear using the -= operator. We return the result for each set operation.

Code

local(d) = date('2011-02-21 08:00:00')
#d->weekofyear + '<br>'
#d->weekofyear=52
#d + '<br>'
#d->weekofyear+=1
#d + '<br>'
#d->weekofyear-=1
#d

Result

8
2011-12-26 08:00:00
2012-01-02 08:00:00
2011-12-26 08:00:00

Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft