User:anbrcyp > ISO 8601 Week-date Functions

ISO 8601 Week-date Functions

Table of contents
  1. 1. Date.Format
      1. 1.1.1. Usage Restrictions
      2. 1.1.2. Parameters
      3. 1.1.3. Result
      4. 1.1.4. Samples
  2. 2. Date.ISOWeek
      1. 2.1.1. Usage Restrictions
      2. 2.1.2. Parameters
      3. 2.1.3. Result
      4. 2.1.4. Samples
  3. 3. Date.ParseISOWeek
      1. 3.1.1. Usage Restrictions
      2. 3.1.2. Parameters
      3. 3.1.3. Result
      4. 3.1.4. Samples

From the following forum thread (http://forums.developer.mindtouch.co...8372#post18372).  The attached zip file contains the diff and modified DekiScriptLibrary.cs (based off 8.05.2b source).

   

Date.Format

date.Format(datetime : str, format : str) : str 

Formats a date according to the specified format string.  See .Net documentation for formatting date-time for more information on format strings.

Usage Restrictions

1.8.1 or later.

8.08 or later for ISO week-date formats.

Parameters

Name Type Description
datetime str The date to format.
format str

The format string.  Additional ISO 8601 week-date formats available:

Format Content Example: "12/31/2007"
 "iso-yyyy-Www-d"  yyyy-Www-d  "2008-W01-1"
 "iso-yyyy-Www"  yyyy-Www-d  "2008-W01"
 "iso-Www-d"  yyyy-Www-d  "W01-1"
 "iso-yyyy"  yyyy-Www-d  "2008"
 "iso-Www"  yyyy-Www-d  "W01"
 "iso-d"  yyyy-Www-d  "1"

Result

Date formatted according to the format string.

Samples

       Output

To display the current date using the full date/time pattern:

{{ date.Format(date.now, "F") }} 

Thursday, January 08, 2009 12:29:04 PM

To display a constant date using a custom format:

{{ date.Format("01/01/2000", "dd-MM-yy") }} 

01-01-00

      

   

Date.ISOWeek

date.ISOWeek(datetime : str) : map

Takes a standard date string and returns the numeric values of an ISO 8601 week-date as a map.  

Usage Restrictions

8.08 or later

Parameters

Name Type Description
datetime str The standard format date to translate.
map enum

Selected portion of an ISO week-date.

Map name Selected Value Example: "12/31/2007"
 year  yyyy-Www-d  2008
 week  yyyy-Www-d  1
 day  yyyy-Www-d  1

Result

Numeric value of the year, week, or day of a standard date in ISO 8601 week-date form.  All values are returned in map format and can be accessed by name.

Samples

                   Output

To get the ISO week-date year of the current date:

{{ date.ISOWeek(date.now).year }}

{ day : 4, week : 2, year : 2009 }

   

Date.ParseISOWeek

date.ParseISOWeek(isoweekdate : str) : str

Takes a full ISO 8601 week-date (yyyy-Www-d) and translates it back to a standard date string.

Usage Restrictions

8.08 or later

Parameters

Name Type Description
isoweekdate str The ISO 8601 format week-date to translate.

Result

A standard date in short format.

Samples

                   Output

To display a full ISO 8601 week-date as a standard date:

{{ date.ParseISOWeek("1999-W52-6") }} 
1/1/2000

Use the output in another date function:

{{ date.date(date.ParseISOWeek("1999-W52-6")) }} 
Sat, 01 Jan 2000

   

Tag page

Files 1

FileSizeDateAttached by 
 date_isoweek.zip
ISO Week Files
18.56 kB22:15, 12 Aug 2008anbrcypActions
You must login to post a comment.
Powered by MindTouch Deki v.8.08.2