Арифметические операторы для продолжительности, дат и времени

В XPath и XQuery для выполнения арифметических действий над данными продолжительности определены следующие операторы:

· op:add-yearMonthDurations($arg1 as xs:yearMonthDuration, $arg2 as xs:yearMonthDuration) as xs:yearMonthDuration – возвращает результат сложения $arg1 и $arg2;

· op:subtract-yearMonthDurations($arg1 as xs:yearMonthDuration, $arg2 as xs:yearMonthDuration) as xs:yearMonthDuration

· op:multiply-yearMonthDuration($arg1 as xs:yearMonthDuration, $arg2 as xs:double) as xs:yearMonthDuration – возвращает результат умножения $arg1 на $arg2;

· op:divide-yearMonthDuration($arg1 as xs:yearMonthDuration, $arg2 as xs:double) as xs:yearMonthDuration

· op:divide-yearMonthDuration-by-yearMonthDuration($arg1 as xs:yearMonthDuration, $arg2 as xs:yearMonthDuration) as xs:decimal – возвращает результат деления $arg1 на $arg2;

· op:add-dayTimeDurations($arg1 as xs:dayTimeDuration, $arg2 as xs:dayTimeDuration) as xs:dayTimeDuration – возвращает результат сложения $arg1 и $arg2;

· op:subtract-dayTimeDurations($arg1 as xs:dayTimeDuration, $arg2 as xs:dayTimeDuration) as xs:dayTimeDuration – возвращает результат вычитания $arg1 и $arg2;

· op:multiply-dayTimeDuration( $arg1 as xs:dayTimeDuration, $arg2 as xs:double) as xs:dayTimeDuration – возвращает результат умножения $arg1 на $arg2;

· op:divide-dayTimeDuration( $arg1 as xs:dayTimeDuration, $arg2 as xs:double) as s:dayTimeDuration – возвращает результат деления $arg1 на $arg2;

· op:divide-dayTimeDuration-by-dayTimeDuration( $arg1 as xs:dayTimeDuration, $arg2 as xs:dayTimeDuration) as xs:decimal – возвращает результат деления $arg1 на $arg2.

 

Примеры использования арифметических операторов для продолжительности:

1. op:add-yearMonthDurations(xs:yearMonthDuration("P1Y11M"), xs:yearMonthDuration("P4Y2M")) – возвращает P6Y1M.

2. op:subtract-yearMonthDurations(xs:yearMonthDuration("P3Y11M"), xs:yearMonthDuration("P3Y3M")) – возвращает P0Y8M.

3. op:multiply-yearMonthDuration(

xs:yearMonthDuration("P1Y10M"), 2) – возвращает P3Y8M.

4. op:divide-yearMonthDuration(

xs:yearMonthDuration("P2Y10M"), 2) – возвращает P1Y5M.

5. op:divide-yearMonthDuration-by-yearMonthDuration(

xs:yearMonthDuration("P3Y4M"),

xs:yearMonthDuration("-P1Y4M")) – возвращает -2.5.

6. op:add-dayTimeDurations(

xs:dayTimeDuration("P1DT12H5M"),

xs:dayTimeDuration("P7DT12H")) – возвращает P9DT00H5M.

7. op:subtract-dayTimeDurations(

xs:dayTimeDuration("P3DT12H"),

xs:dayTimeDuration("P1DT09H30M")) – возвращает P2D02H30M.

8. op:multiply-dayTimeDuration(

xs:dayTimeDuration("PT3H17M"), 2) – возвращает PT6H34M.

9. op:divide-dayTimeDuration(

xs:yearMonthDuration("P2DT3H30M"), 2) – возвращает P1DT1H45M.

10. op:divide-dayTimeDuration-by-dayTimeDuration(

xs:dayTimeDuration("P2DT53M11S"),

xs:dayTimeDuration("P1DT10H)) – возвращает 1.4378349.

 

Кроме приведенных выше операторов в XPath и XQuery для выполнения арифметических действий над данными продолжительности, дат и времени определены следующие операторы:

· op:subtract-dateTimes($arg1 as xs:dateTime, $arg2 as xs:dateTime) as xs:dayTimeDuration? – возвращает разницу между нормализованными значениями $arg1 и $arg2;

· op:subtract-dates($arg1 as xs:date, $arg2 as xs:date) as xs:dayTimeDuration? – возвращает разницу между значениями $arg1 и $arg2;

· op:subtract-times($arg1 as xs:time, $arg2 as xs:time) as xs:dayTimeDuration – возвращает разницу между преобразованными в xs:dateTime значениями $arg1 и $arg2;

· op:add-yearMonthDuration-to-dateTime($arg1 as xs:dateTime, $arg2 as xs:yearMonthDuration) as xs:dateTime – возвращает сумму значений $arg1 и $arg2;

· op:add-dayTimeDuration-to-dateTime($arg1 as xs:dateTime, $arg2 as xs:dayTimeDuration) as xs:dateTime – возвращает сумму значений $arg1 и $arg2;

· op:subtract-yearMonthDuration-from-dateTime($arg1 as xs:dateTime, $arg2 as xs:yearMonthDuration) as xs:dateTime – возвращает разницу значений $arg1 и $arg2;

· op:subtract-dayTimeDuration-from-dateTime($arg1 as xs:dateTime, $arg2 as xs:dayTimeDuration) as xs:dateTime – возвращает разницу значений $arg1 и $arg2;

· op:add-yearMonthDuration-to-date($arg1 as xs:date, $arg2 as xs:yearMonthDuration) as xs:date – возвращает сумму значений $arg1 и $arg2;

· op:add-dayTimeDuration-to-date( $arg1 as xs:date, $arg2 as xs:dayTimeDuration) as xs:date – возвращает сумму значений $arg1 и $arg2;

· op:subtract-yearMonthDuration-from-date($arg1 as xs:date, $arg2 as xs:yearMonthDuration) as xs:date – возвращает разницу значений $arg1 и $arg2;

· op:subtract-dayTimeDuration-from-date($arg1 as xs:date, $arg2 as xs:dayTimeDuration) as xs:date – возвращает разницу значений $arg1 и $arg2;

· op:add-dayTimeDuration-to-time( $arg1 as xs:time, $arg2 as xs:dayTimeDuration) as xs:time – возвращает сумму значений $arg1 и $arg2;

· op:subtract-dayTimeDuration-from-time( $arg1 as xs:time, $arg2 as xs:dayTimeDuration) as xs:time – возвращает разницу значений $arg1 и $arg2.

 

Примеры использования арифметических операторов для продолжительности, дат и времени:

1. op:subtract-dateTimes(xs:dateTime("2001-10-30T06:12:00"), xs:dateTime("2000-11-28T09:00:00Z")) – возвращает P0Y0M337T2H12M.

2. op:subtract-dates(xs:date("2000-09-15-05:00"), xs:date("2000-09-11+02:00")) – возвращает P4DT7H.

3. op:subtract-times(xs:time("11:12:00Z"), xs:time("04:00:00")) – возвращает PT2H12M.

4. op:add-yearMonthDuration-to-dateTime(

xs:dateTime("2000-10-30T11:12:00"),

xs:yearMonthDuration("P1Y2M")) – возвращает

"2001-12-30T11:12:00".

5. op:add-dayTimeDuration-to-dateTime(

xs:dateTime("2000-10-30T11:12:00"),

xs:dayTimeDuration("P3DT1H15M")) – возвращает

"2000-11-02T12:27:00".

6. op:subtract-yearMonthDuration-from-dateTime(

xs:dateTime("2000-10-30T11:12:00"),

xs:yearMonthDuration("P1Y2M")) – возвращает

"1999-08-30T11:12:00".

7. op:subtract-dayTimeDuration-from-dateTime(

xs:dateTime("2000-10-30T11:12:00"),

xs:dayTimeDuration("P3DT1H15M")) – возвращает

"2000-10-27T09:57:00".

8. op:add-yearMonthDuration-to-date(

xs:date("2000-10-30"),

xs:yearMonthDuration("P1Y2M")) – возвращает "2001-12-30".

9. op:add-dayTimeDuration-to-date(

xs:date("2004-10-30Z"),

xs:dayTimeDuration("P2DT2H30M0S")) – возвращает "2004-11-01".

10. op:subtract-yearMonthDuration-from-date(

xs:date("2000-10-30"),

xs:yearMonthDuration("P1Y2M")) – возвращает "1999-08-30".

11. op:subtract-dayTimeDuration-from-date(

xs:date("2000-10-30"),

xs:dayTimeDuration("P3DT1H15M")) – возвращает "2000-10-26".

12. op:add-dayTimeDuration-to-time(

xs:time("11:12:00"),

xs:dayTimeDuration("P3DT1H15M")) – возвращает "12:27:00".

13. op:subtract-dayTimeDuration-from-time(

xs:time("11:12:00"),

xs:dayTimeDuration("P3DT1H15M")) – возвращает "09:57:00".








Дата добавления: 2015-03-19; просмотров: 1479;


Поиск по сайту:

При помощи поиска вы сможете найти нужную вам информацию.

Поделитесь с друзьями:

Если вам перенёс пользу информационный материал, или помог в учебе – поделитесь этим сайтом с друзьями и знакомыми.
helpiks.org - Хелпикс.Орг - 2014-2024 год. Материал сайта представляется для ознакомительного и учебного использования. | Поддержка
Генерация страницы за: 0.014 сек.