TimeSpanFunctions.

GetDays(TimeSpan) Method

Summary

Returns the number of whole days represented by the specified System.TimeSpan.
Assembly
NAnt.Core.dll
Namespace
NAnt.Core.Functions
Containing Type
TimeSpanFunctions

Syntax

[Function("get-days")]
public static int GetDays(TimeSpan value)

Examples

Remove all files that have not been modified in the last 7 days from directory "binaries".

    <foreach item="File" in="binaries" property="filename">
    <if test="${timespan::get-days(datetime::now() - file::get-last-write-time(filename)) >= 7}">
        <delete file="${filename}" />
    </if>
</foreach>

Attributes

Type Description
FunctionAttribute Indicates that the method should be exposed as a function in NAnt build files.

Parameters

Name Type Description
value TimeSpan A System.TimeSpan.

Return Value

Type Description
int The number of whole days represented by the given System.TimeSpan.