Project.GetDuration

GetDuration(double)

Gets Duration object with the specified number of units and default duration format which is defined in project’s settings DurationFormat.

public Duration GetDuration(double val)
ParameterTypeDescription
valDoublespecified number of units.

Return Value

Duration object.

Remarks

This method should be used carefully because it returns different durations depending on Project.DurationFormat setting. For example, GetWork(1.0) will return 1 hour when Project.DurationFormat is TimeUnitType.Hour or 1 day if Project.DurationFormat is TimeUnitType.Day.

Examples

Shows how to create a <see cref=“Aspose.Tasks.Duration” /> instance with default project’s duration format by using project fabric methods.

var project = new Project();

// get a duration with default project format.
var duration = project.GetDuration(1);

Console.WriteLine("Default project duration time unit type: " + project.Get(Prj.DurationFormat));
Console.WriteLine("Created duration time unit type: " + duration.TimeUnit);

See Also


GetDuration(double, TimeUnitType)

Gets Duration object with the specified number of TimeUnitType units.

public Duration GetDuration(double val, TimeUnitType timeUnit)
ParameterTypeDescription
valDoublespecified number of units.
timeUnitTimeUnitTypespecified TimeUnitType value.

Return Value

Duration object.

Examples

Shows how to create a <see cref=“Aspose.Tasks.Duration” /> instance by using project fabric methods.

var project = new Project();

// get a duration with default project format.
var duration = project.GetDuration(1, TimeUnitType.Minute);

Console.WriteLine("Created duration: " + duration);

See Also


GetDuration(TimeSpan, TimeUnitType)

Gets Duration object with the specified TimeSpan value and specified TimeUnitType value.

public Duration GetDuration(TimeSpan timeSpan, TimeUnitType timeUnit)
ParameterTypeDescription
timeSpanTimeSpanspecified TimeSpan value.
timeUnitTimeUnitTypespecified TimeUnitType value.

Return Value

Duration object.

See Also