isLeapYear

DataWeave 2.1 is compatible with Mule 4.1. Standard Support for Mule 4.1 ended on November 2, 2020, and this version of Mule will reach its End of Life on November 2, 2022, when Extended Support ends.

Deployments of new applications to CloudHub that use this version of Mule are no longer allowed. Only in-place updates to applications are permitted.

MuleSoft recommends that you upgrade to the latest version of Mule 4 that is in Standard Support so that your applications run with the latest fixes and security enhancements.

isLeapYear(DateTime): Boolean

Returns true if it receives a DateTime for a leap year, false if not.

Parameters

Name Description

dateTime

The date-time (DateTime type) to evaluate.

Example

This example indicates whether the input is a leap year.

Source

%dw 2.0
output application/json
---
{
  "leapYear" : isLeapYear(|2016-10-01T23:57:59Z|),
  "leapYear" : isLeapYear(|2016-10-01T23:57:59-03:00|),
  "leapYear": isLeapYear(|2017-10-01T23:57:59Z|),
  "leapYear": isLeapYear(|2017-10-01T23:57:59-03:00|)
}

Output

  {
    "leapYear": true,
    "leapYear": true,
    "leapYear": false,
    "leapYear": false
  }

isLeapYear(Date): Boolean

Returns true if the input Date is a leap year, 'false' if not.

Parameters

Name Description

date

The date (Date type) to evaluate.

Example

This example indicates whether the input is a leap year.

Source

%dw 2.0
output application/json
---
{
  "leapYear" : isLeapYear(|2016-10-01|),
  "leapYear": isLeapYear(|2017-10-01|)
}

Output

  {
    "leapYear": true,
    "leapYear": false
  }

isLeapYear(LocalDateTime): Boolean

Returns true if the input local date-time is a leap year, 'false' if not.

Parameters

Name Description

datetime

A local date-time (LocalDateTime type) to evaluate.

Example

This example indicates whether the input is a leap year.

Source

%dw 2.0
output application/json
---
{
  "leapYear" : isLeapYear(|2016-10-01T23:57:59|),
  "leapYear": isLeapYear(|2017-10-01T23:57:59|)
}

Output

  {
    "leapYear": true,
    "leapYear": false
  }

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub