1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725
|
<pre>Network Working Group N. Freed
Request for Comments: 5260 Sun Microsystems
Category: Standards Track July 2008
<span class="h1">Sieve Email Filtering: Date and Index Extensions</span>
Status of This Memo
This document specifies an Internet standards track protocol for the
Internet community, and requests discussion and suggestions for
improvements. Please refer to the current edition of the "Internet
Official Protocol Standards" (STD 1) for the standardization state
and status of this protocol. Distribution of this memo is unlimited.
Abstract
This document describes the "date" and "index" extensions to the
Sieve email filtering language. The "date" extension gives Sieve the
ability to test date and time values in various ways. The "index"
extension provides a means to limit header and address tests to
specific instances of header fields when header fields are repeated.
Table of Contents
<a href="#section-1">1</a>. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-2">2</a>
<a href="#section-2">2</a>. Conventions Used in This Document . . . . . . . . . . . . . . <a href="#page-2">2</a>
<a href="#section-3">3</a>. Capability Identifiers . . . . . . . . . . . . . . . . . . . . <a href="#page-3">3</a>
<a href="#section-4">4</a>. Date Test . . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-3">3</a>
<a href="#section-4.1">4.1</a>. Zone and Originalzone Arguments . . . . . . . . . . . . . <a href="#page-4">4</a>
<a href="#section-4.2">4.2</a>. Date-part Argument . . . . . . . . . . . . . . . . . . . . <a href="#page-4">4</a>
<a href="#section-4.3">4.3</a>. Comparator Interactions with Date-part Arguments . . . . . <a href="#page-5">5</a>
<a href="#section-4.4">4.4</a>. Examples . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-6">6</a>
<a href="#section-5">5</a>. Currentdate Test . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-6">6</a>
<a href="#section-5.1">5.1</a>. Examples . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-6">6</a>
<a href="#section-6">6</a>. Index Extension . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-7">7</a>
<a href="#section-6.1">6.1</a>. Example . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-8">8</a>
<a href="#section-7">7</a>. Security Considerations . . . . . . . . . . . . . . . . . . . <a href="#page-8">8</a>
<a href="#section-8">8</a>. IANA Considerations . . . . . . . . . . . . . . . . . . . . . <a href="#page-9">9</a>
<a href="#section-9">9</a>. References . . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-9">9</a>
<a href="#section-9.1">9.1</a>. Normative References . . . . . . . . . . . . . . . . . . . <a href="#page-9">9</a>
<a href="#section-9.2">9.2</a>. Informative References . . . . . . . . . . . . . . . . . . <a href="#page-10">10</a>
<a href="#appendix-A">Appendix A</a>. Julian Date Conversions . . . . . . . . . . . . . . . <a href="#page-11">11</a>
<a href="#appendix-B">Appendix B</a>. Acknowledgements . . . . . . . . . . . . . . . . . . <a href="#page-12">12</a>
<span class="grey">Freed Standards Track [Page 1]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-2" ></span>
<span class="grey"><a href="./rfc5260">RFC 5260</a> Sieve Date and Index Extensions July 2008</span>
<span class="h2"><a class="selflink" id="section-1" href="#section-1">1</a>. Introduction</span>
Sieve [<a href="./rfc5228" title=""Sieve: An Email Filtering Language"">RFC5228</a>] is a language for filtering email messages at or
around the time of final delivery. It is designed to be
implementable on either a mail client or mail server. It is meant to
be extensible, simple, and independent of access protocol, mail
architecture, and operating system. It is suitable for running on a
mail server where users may not be allowed to execute arbitrary
programs, such as on black box Internet Message Access Protocol
[<a href="./rfc3501" title=""INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1"">RFC3501</a>] servers, as it does not have user-controlled loops or the
ability to run external programs.
The "date" extension provides a new date test to extract and match
date/time information from structured header fields. The date test
is similar in concept to the address test specified in [<a href="./rfc5228" title=""Sieve: An Email Filtering Language"">RFC5228</a>],
which performs similar operations on addresses in header fields.
The "date" extension also provides a currentdate test that operates
on the date and time when the Sieve script is executed.
Some header fields containing date/time information, e.g., Received:,
naturally occur more than once in a single header. In such cases it
is useful to be able to restrict the date test to some subset of the
fields that are present. For example, it may be useful to apply a
date test to the last (earliest) Received: field. Additionally, it
may also be useful to apply similar restrictions to either the header
or address tests specified in [<a href="./rfc5228" title=""Sieve: An Email Filtering Language"">RFC5228</a>].
For this reason, this specification also defines an "index"
extension. This extension adds two additional tagged arguments
:index and :last to the header, address, and date tests. If present,
these arguments specify which occurrence of the named header field is
to be tested.
<span class="h2"><a class="selflink" id="section-2" href="#section-2">2</a>. Conventions Used in This Document</span>
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in <a href="./rfc2119">RFC 2119</a> [<a href="./rfc2119" title=""Key words for use in RFCs to Indicate Requirement Levels"">RFC2119</a>].
The terms used to describe the various components of the Sieve
language are taken from <a href="./rfc5228#section-1.1">Section 1.1 of [RFC5228]</a>. <a href="#section-2">Section 2</a> of the
same document describes basic Sieve language syntax and semantics.
The date-time syntactic element defined using ABNF notation [<a href="./rfc5234" title=""Augmented BNF for Syntax Specifications: ABNF"">RFC5234</a>]
in [<a href="./rfc3339" title=""Date and Time on the Internet: Timestamps"">RFC3339</a>] is also used here.
<span class="grey">Freed Standards Track [Page 2]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-3" ></span>
<span class="grey"><a href="./rfc5260">RFC 5260</a> Sieve Date and Index Extensions July 2008</span>
<span class="h2"><a class="selflink" id="section-3" href="#section-3">3</a>. Capability Identifiers</span>
The capability strings associated with the two extensions defined in
this document are "date" and "index".
<span class="h2"><a class="selflink" id="section-4" href="#section-4">4</a>. Date Test</span>
Usage: date [<":zone" <time-zone: string>> / ":originalzone"]
[COMPARATOR] [MATCH-TYPE] <header-name: string>
<date-part: string> <key-list: string-list>
The date test matches date/time information derived from headers
containing [<a href="./rfc2822" title=""Internet Message Format"">RFC2822</a>] date-time values. The date/time information is
extracted from the header, shifted to the specified time zone, and
the value of the given date-part is determined. The test returns
true if the resulting string matches any of the strings specified in
the key-list, as controlled by the comparator and match keywords.
The date test returns false unconditionally if the specified header
field does not exist, the field exists but does not contain a
syntactically valid date-time specification, the date-time isn't
valid according to the rules of the calendar system (e.g., January
32nd, February 29 in a non-leap year), or the resulting string fails
to match any key-list value.
The type of match defaults to ":is" and the default comparator is
"i;ascii-casemap".
Unlike the header and address tests, the date test can only be
applied to a single header field at a time. If multiple header
fields with the same name are present, only the first field that is
found is used. (Note, however, that this behavior can be modified
with the "index" extension defined below.) These restrictions
simplify the test and keep the meaning clear.
The "relational" extension [<a href="./rfc5231" title=""Sieve Email Filtering: Relational Extension"">RFC5231</a>] adds a match type called
":count". The count of a date test is 1 if the specified field
exists and contains a valid date; 0, otherwise.
Implementations MUST support extraction of <a href="./rfc2822">RFC 2822</a> date-time
information that either makes up the entire header field (e.g., as it
does in a standard Date: header field) or appears at the end of a
header field following a semicolon (e.g., as it does in a standard
Received: header field). Implementations MAY support extraction of
date and time information in <a href="./rfc2822">RFC2822</a> or other formats that appears in
other positions in header field content. In the case of a field
containing more than one date or time value, the last one that
appears SHOULD be used.
<span class="grey">Freed Standards Track [Page 3]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-4" ></span>
<span class="grey"><a href="./rfc5260">RFC 5260</a> Sieve Date and Index Extensions July 2008</span>
<span class="h3"><a class="selflink" id="section-4.1" href="#section-4.1">4.1</a>. Zone and Originalzone Arguments</span>
The :originalzone argument specifies that the time zone offset
originally in the extracted date-time value should be retained. The
:zone argument specifies a specific time zone offset that the date-
time value is to be shifted to prior to testing. It is an error to
specify both :zone and :originalzone.
The value of time-zone MUST be an offset relative to UTC with the
following syntax:
time-zone = ( "+" / "-" ) 4DIGIT
The "+" or "-" indicates whether the time-of-day is ahead of (i.e.,
east of) or behind (i.e., west of) UTC. The first two digits
indicate the number of hours difference from Universal Time, and the
last two digits indicate the number of minutes difference from
Universal Time. Note that this agrees with the <a href="./rfc2822">RFC 2822</a> format for
time zone offsets, not the ISO 8601 format.
If both the :zone and :originalzone arguments are omitted, the local
time zone MUST be used.
<span class="h3"><a class="selflink" id="section-4.2" href="#section-4.2">4.2</a>. Date-part Argument</span>
The date-part argument specifies a particular part of the resulting
date/time value to match against the key-list. Possible case-
insensitive values are:
"year" => the year, "0000" .. "9999".
"month" => the month, "01" .. "12".
"day" => the day, "01" .. "31".
"date" => the date in "yyyy-mm-dd" format.
"julian" => the Modified Julian Day, that is, the date
expressed as an integer number of days since
00:00 UTC on November 17, 1858 (using the Gregorian
calendar). This corresponds to the regular
Julian Day minus 2400000.5. Sample routines to
convert to and from modified Julian dates are
given in <a href="#appendix-A">Appendix A</a>.
"hour" => the hour, "00" .. "23".
"minute" => the minute, "00" .. "59".
"second" => the second, "00" .. "60".
"time" => the time in "hh:mm:ss" format.
"iso8601" => the date and time in restricted ISO 8601 format.
"std11" => the date and time in a format appropriate
for use in a Date: header field [<a href="./rfc2822" title=""Internet Message Format"">RFC2822</a>].
<span class="grey">Freed Standards Track [Page 4]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-5" ></span>
<span class="grey"><a href="./rfc5260">RFC 5260</a> Sieve Date and Index Extensions July 2008</span>
"zone" => the time zone in use. If the user specified a
time zone with ":zone", "zone" will
contain that value. If :originalzone is specified
this value will be the original zone specified
in the date-time value. If neither argument is
specified the value will be the server's default
time zone in offset format "+hhmm" or "-hhmm". An
offset of 0 (Zulu) always has a positive sign.
"weekday" => the day of the week expressed as an integer between
"0" and "6". "0" is Sunday, "1" is Monday, etc.
The restricted ISO 8601 format is specified by the date-time ABNF
production given in <a href="./rfc3339#section-5.6">[RFC3339], Section 5.6</a>, with the added
restrictions that the letters "T" and "Z" MUST be in upper case, and
a time zone offset of zero MUST be represented by "Z" and not
"+00:00".
<span class="h3"><a class="selflink" id="section-4.3" href="#section-4.3">4.3</a>. Comparator Interactions with Date-part Arguments</span>
Not all comparators are suitable with all date-part arguments. In
general, the date-parts can be compared and tested for equality with
either "i;ascii-casemap" (the default) or "i;octet", but there are
two exceptions:
julian This is an integer, and may or may not have leading zeros.
As such, "i;ascii-numeric" is almost certainly the best
comparator to use with it.
std11 This is provided as a means to obtain date/time values in a
format appropriate for inclusion in email header fields. The
wide range of possible syntaxes for a std11 date/time --
which implementations of this extension are free to use when
composing a std11 string -- makes this format a poor choice
for comparisons. Nevertheless, if a comparison must be
performed, this is case-insensitive, and therefore "i;ascii-
casemap" needs to be used.
"year", "month", "day", "hour", "minute", "second" and "weekday" all
use fixed-width string representations of integers, and can therefore
be compared with "i;octet", "i;ascii-casemap", and "i;ascii-numeric"
with equivalent results.
"date" and "time" also use fixed-width string representations of
integers, and can therefore be compared with "i;octet" and "i;ascii-
casemap"; however, "i;ascii-numeric" can't be used with it, as
"i;ascii-numeric" doesn't allow for non-digit characters.
<span class="grey">Freed Standards Track [Page 5]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-6" ></span>
<span class="grey"><a href="./rfc5260">RFC 5260</a> Sieve Date and Index Extensions July 2008</span>
<span class="h3"><a class="selflink" id="section-4.4" href="#section-4.4">4.4</a>. Examples</span>
The Date: field can be checked to test when the sender claims to have
created the message and act accordingly:
require ["date", "relational", "fileinto"];
if allof(header :is "from" "boss@example.com",
date :value "ge" :originalzone "date" "hour" "09",
date :value "lt" :originalzone "date" "hour" "17")
{ fileinto "urgent"; }
Testing the initial Received: field can provide an indication of when
a message was actually received by the local system:
require ["date", "relational", "fileinto"];
if anyof(date :is "received" "weekday" "0",
date :is "received" "weekday" "6")
{ fileinto "weekend"; }
<span class="h2"><a class="selflink" id="section-5" href="#section-5">5</a>. Currentdate Test</span>
Usage: currentdate [":zone" <time-zone: string>]
[COMPARATOR] [MATCH-TYPE]
<date-part: string>
<key-list: string-list>
The currentdate test is similar to the date test, except that it
operates on the current date/time rather than a value extracted from
the message header. In particular, the ":zone" and date-part
arguments are the same as those in the date test.
All currentdate tests in a single Sieve script MUST refer to the same
point in time during execution of the script.
The :count value of a currentdate test is always 1.
<span class="h3"><a class="selflink" id="section-5.1" href="#section-5.1">5.1</a>. Examples</span>
The simplest use of currentdate is to have an action that only
operates at certain times. For example, a user might want to have
messages redirected to their pager after business hours and on
weekends:
<span class="grey">Freed Standards Track [Page 6]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-7" ></span>
<span class="grey"><a href="./rfc5260">RFC 5260</a> Sieve Date and Index Extensions July 2008</span>
require ["date", "relational"];
if anyof(currentdate :is "weekday" "0",
currentdate :is "weekday" "6",
currentdate :value "lt" "hour" "09",
currentdate :value "ge" "hour" "17")
{ redirect "pager@example.com"; }
Currentdate can be used to set up vacation [<a href="./rfc5230" title=""Sieve Email Filtering: Vacation Extension"">RFC5230</a>] responses in
advance and to stop response generation automatically:
require ["date", "relational", "vacation"];
if allof(currentdate :value "ge" "date" "2007-06-30",
currentdate :value "le" "date" "2007-07-07")
{ vacation :days 7 "I'm away during the first week in July."; }
Currentdate may also be used in conjunction with the variables
extension to pass time-dependent arguments to other tests and
actions. The following Sieve places messages in a folder named
according to the current month and year:
require ["date", "variables", "fileinto"];
if currentdate :matches "month" "*" { set "month" "${1}"; }
if currentdate :matches "year" "*" { set "year" "${1}"; }
fileinto "${month}-${year}";
Finally, currentdate can be used in conjunction with the editheader
extension to insert a header-field containing date/time information:
require ["variables", "date", "editheader"];
if currentdate :matches "std11" "*"
{addheader "Processing-date" "${0}";}
<span class="h2"><a class="selflink" id="section-6" href="#section-6">6</a>. Index Extension</span>
The "index" extension, if specified, adds optional :index and :last
arguments to the header, address, and date tests as follows:
Syntax: date [":index" <fieldno: number> [":last"]]
[<":zone" <time-zone: string>> / ":originalzone"]
[COMPARATOR] [MATCH-TYPE] <header-name: string>
<date-part: string> <key-list: string-list>
Syntax: header [":index" <fieldno: number> [":last"]]
[COMPARATOR] [MATCH-TYPE]
<header-names: string-list> <key-list: string-list>
<span class="grey">Freed Standards Track [Page 7]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-8" ></span>
<span class="grey"><a href="./rfc5260">RFC 5260</a> Sieve Date and Index Extensions July 2008</span>
Syntax: address [":index" <fieldno: number> [":last"]]
[ADDRESS-PART] [COMPARATOR] [MATCH-TYPE]
<header-list: string-list> <key-list: string-list>
If :index <fieldno> is specified, the attempts to match a value are
limited to the header field fieldno (beginning at 1, the first named
header field). If :last is also specified, the count is backwards; 1
denotes the last named header field, 2 the second to last, and so on.
Specifying :last without :index is an error.
:index only counts separate header fields, not multiple occurrences
within a single field. In particular, :index cannot be used to test
a specific address in an address list contained within a single
header field.
Both header and address allow the specification of more than one
header field name. If more than one header field name is specified,
all the named header fields are counted in the order specified by the
header-list.
<span class="h3"><a class="selflink" id="section-6.1" href="#section-6.1">6.1</a>. Example</span>
Mail delivery may involve multiple hops, resulting in the Received:
field containing information about when a message first entered the
local administrative domain being the second or subsequent field in
the message. As long as the field offset is consistent, it can be
tested:
# Implement the Internet-Draft cutoff date check assuming the
# second Received: field specifies when the message first
# entered the local email infrastructure.
require ["date", "relational", "index"];
if date :value "gt" :index 2 :zone "-0500" "received"
"iso8601" "2007-02-26T09:00:00-05:00",
{ redirect "aftercutoff@example.org"; }
<span class="h2"><a class="selflink" id="section-7" href="#section-7">7</a>. Security Considerations</span>
The facilities defined here, like the facilities in the base Sieve
specification, operate on message header information that can easily
be forged. Note, however, that some fields are inherently more
reliable than others. For example, the Date: field is typically
inserted by the message sender and can be altered at any point. By
contrast, the uppermost Received: field is typically inserted by the
local mail system and is therefore difficult for the sender or an
intermediary to falsify.
<span class="grey">Freed Standards Track [Page 8]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-9" ></span>
<span class="grey"><a href="./rfc5260">RFC 5260</a> Sieve Date and Index Extensions July 2008</span>
Use of the currentdate test makes script behavior inherently less
predictable and harder to analyze. This may have consequences for
systems that use script analysis to try and spot problematic scripts.
All of the security considerations given in the base Sieve
specification also apply to these extensions.
<span class="h2"><a class="selflink" id="section-8" href="#section-8">8</a>. IANA Considerations</span>
The following templates specify the IANA registrations of the two
Sieve extensions specified in this document:
To: iana@iana.org
Subject: Registration of new Sieve extensions
Capability name: date
Description: The "date" extension gives Sieve the ability
to test date and time values.
RFC number: <a href="./rfc5260">RFC 5260</a>
Contact address: Sieve discussion list <ietf-mta-filters@imc.org>
Capability name: index
Description: The "index" extension provides a means to
limit header and address tests to specific
instances when more than one field of a
given type is present.
RFC number: <a href="./rfc5260">RFC 5260</a>
Contact address: Sieve discussion list <ietf-mta-filters@imc.org>
<span class="h2"><a class="selflink" id="section-9" href="#section-9">9</a>. References</span>
<span class="h3"><a class="selflink" id="section-9.1" href="#section-9.1">9.1</a>. Normative References</span>
[<a id="ref-CALGO199">CALGO199</a>] Tantzen, R., "Algorithm 199: Conversions Between Calendar
Date and Julian Day Number", Collected Algorithms from
CACM 199.
[<a id="ref-RFC2119">RFC2119</a>] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", <a href="https://www.rfc-editor.org/bcp/bcp14">BCP 14</a>, <a href="./rfc2119">RFC 2119</a>, March 1997.
[<a id="ref-RFC2822">RFC2822</a>] Resnick, P., "Internet Message Format", <a href="./rfc2822">RFC 2822</a>,
April 2001.
[<a id="ref-RFC3339">RFC3339</a>] Klyne, G., Ed. and C. Newman, "Date and Time on the
Internet: Timestamps", <a href="./rfc3339">RFC 3339</a>, July 2002.
[<a id="ref-RFC5228">RFC5228</a>] Guenther, P. and T. Showalter, "Sieve: An Email Filtering
Language", <a href="./rfc5228">RFC 5228</a>, January 2008.
<span class="grey">Freed Standards Track [Page 9]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-10" ></span>
<span class="grey"><a href="./rfc5260">RFC 5260</a> Sieve Date and Index Extensions July 2008</span>
[<a id="ref-RFC5231">RFC5231</a>] Segmuller, W. and B. Leiba, "Sieve Email Filtering:
Relational Extension", <a href="./rfc5231">RFC 5231</a>, January 2008.
[<a id="ref-RFC5234">RFC5234</a>] Crocker, D. and P. Overell, "Augmented BNF for Syntax
Specifications: ABNF", STD 68, <a href="./rfc5234">RFC 5234</a>, January 2008.
<span class="h3"><a class="selflink" id="section-9.2" href="#section-9.2">9.2</a>. Informative References</span>
[<a id="ref-RFC3501">RFC3501</a>] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION
4rev1", <a href="./rfc3501">RFC 3501</a>, March 2003.
[<a id="ref-RFC5230">RFC5230</a>] Showalter, T. and N. Freed, "Sieve Email Filtering:
Vacation Extension", <a href="./rfc5230">RFC 5230</a>, January 2008.
<span class="grey">Freed Standards Track [Page 10]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-11" ></span>
<span class="grey"><a href="./rfc5260">RFC 5260</a> Sieve Date and Index Extensions July 2008</span>
<span class="h2"><a class="selflink" id="appendix-A" href="#appendix-A">Appendix A</a>. Julian Date Conversions</span>
The following C routines show how to translate day/month/year
information to and from modified Julian dates. These routines are
straightforward translations of the Algol routines specified in CACM
Algorithm 199 [<a href="#ref-CALGO199" title=""Algorithm 199: Conversions Between Calendar Date and Julian Day Number"">CALGO199</a>].
Given the day, month, and year, jday returns the modified Julian
date.
int jday(int year, int month, int day)
{
int j, c, ya;
if (month > 2)
month -= 3;
else
{
month += 9;
year--;
}
c = year / 100;
ya = year - c * 100;
return (c * 146097 / 4 + ya * 1461 / 4 + (month * 153 + 2) / 5 +
day + 1721119);
}
<span class="grey">Freed Standards Track [Page 11]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-12" ></span>
<span class="grey"><a href="./rfc5260">RFC 5260</a> Sieve Date and Index Extensions July 2008</span>
Given j, the modified Julian date, jdate returns the day, month, and
year.
void jdate(int j, int *year, int *month, int *day)
{
int y, m, d;
j -= 1721119;
y = (j * 4 - 1) / 146097;
j = j * 4 - y * 146097 - 1;
d = j / 4;
j = (d * 4 + 3) / 1461;
d = d * 4 - j * 1461 + 3;
d = (d + 4) / 4;
m = (d * 5 - 3) / 153;
d = d * 5 - m * 153 - 3;
*day = (d + 5) / 5;
*year = y * 100 + j;
if (m < 10)
*month = m + 3;
else
{
*month = m - 9;
*year += 1;
}
}
<span class="h2"><a class="selflink" id="appendix-B" href="#appendix-B">Appendix B</a>. Acknowledgements</span>
Dave Cridland contributed the text describing the proper comparators
to use with different date-parts. Cyrus Daboo, Frank Ellerman,
Alexey Melnikov, Chris Newman, Dilyan Palauzov, and Aaron Stone
provided helpful suggestions and corrections.
Author's Address
Ned Freed
Sun Microsystems
800 Royal Oaks
Monrovia, CA 91016-6347
USA
Phone: +1 909 457 4293
EMail: ned.freed@mrochek.com
<span class="grey">Freed Standards Track [Page 12]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-13" ></span>
<span class="grey"><a href="./rfc5260">RFC 5260</a> Sieve Date and Index Extensions July 2008</span>
Full Copyright Statement
Copyright (C) The IETF Trust (2008).
This document is subject to the rights, licenses and restrictions
contained in <a href="https://www.rfc-editor.org/bcp/bcp78">BCP 78</a>, and except as set forth therein, the authors
retain all their rights.
This document and the information contained herein are provided on an
"AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS
OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY, THE IETF TRUST AND
THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF
THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Intellectual Property
The IETF takes no position regarding the validity or scope of any
Intellectual Property Rights or other rights that might be claimed to
pertain to the implementation or use of the technology described in
this document or the extent to which any license under such rights
might or might not be available; nor does it represent that it has
made any independent effort to identify any such rights. Information
on the procedures with respect to rights in RFC documents can be
found in <a href="https://www.rfc-editor.org/bcp/bcp78">BCP 78</a> and <a href="https://www.rfc-editor.org/bcp/bcp79">BCP 79</a>.
Copies of IPR disclosures made to the IETF Secretariat and any
assurances of licenses to be made available, or the result of an
attempt made to obtain a general license or permission for the use of
such proprietary rights by implementers or users of this
specification can be obtained from the IETF on-line IPR repository at
<a href="http://www.ietf.org/ipr">http://www.ietf.org/ipr</a>.
The IETF invites any interested party to bring to its attention any
copyrights, patents or patent applications, or other proprietary
rights that may cover technology that may be required to implement
this standard. Please address the information to the IETF at
ietf-ipr@ietf.org.
Freed Standards Track [Page 13]
</pre>
|