Permalink
Browse files

Completed the burnination of the old Parser folder. This is a combine…

…d parser/unparser project now.

--HG--
rename : Unparser/2005-2006.txt => 2005-2006.txt
rename : Unparser/2005.txt => 2005.txt
rename : Unparser/2006.txt => 2006.txt
rename : Unparser/2009-2010.txt => 2009-2010.txt
rename : Unparser/LICENSE.txt => LICENSE.txt
rename : Unparser/Makefile => Makefile
rename : Unparser/NSCalendarDate+ISO8601Parsing.h => NSCalendarDate+ISO8601Parsing.h
rename : Unparser/NSCalendarDate+ISO8601Parsing.m => NSCalendarDate+ISO8601Parsing.m
rename : Unparser/NSCalendarDate+ISO8601Unparsing.h => NSCalendarDate+ISO8601Unparsing.h
rename : Unparser/NSCalendarDate+ISO8601Unparsing.m => NSCalendarDate+ISO8601Unparsing.m
rename : Unparser/README.txt => README.txt
rename : Unparser/januaries.out => januaries.out
rename : Unparser/januaries.txt => januaries.txt
rename : Unparser/januaries3.txt => januaries3.txt
rename : Unparser/testparser.m => testparser.m
rename : Unparser/testparser.sh.in => testparser.sh.in
rename : Unparser/testparser.sh.py => testparser.sh.py
rename : Unparser/testunparser-expected.out => testunparser-expected.out
rename : Unparser/testunparser.out => testunparser.out
rename : Unparser/testunparser.sh => testunparser.sh
rename : Unparser/unparse-date.m => unparse-date.m
rename : Unparser/unparse-ordinaldate.m => unparse-ordinaldate.m
rename : Unparser/unparse-weekdate.m => unparse-weekdate.m
extra : convert_revision : svn%3A126d449c-a017-0410-b042-ab437f2cfecf/trunk%4011
  • Loading branch information...
1 parent b8bcabc commit d14d9ab7a84c2bf708726b7553d6df7d0553bcf4 boredzo committed Jul 2, 2006
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -1,9 +0,0 @@
-Copyright © 2006 Mac-arena the Bored Zo
- All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-Neither the name of Mac-arena the Bored Zo nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View
@@ -1,10 +0,0 @@
-CFLAGS+=-std=c99 -Wall
-LDFLAGS+=-framework Foundation
-
-testprog: testprog.o NSCalendarDate+ISO8601Parsing.o
-
-test.sh: test.sh.in
- python test.sh.py
-.PHONY: test
-test: testprog test.sh
- ./test.sh
View
@@ -1,44 +0,0 @@
-HOW TO USE IN YOUR PROGRAM
-
-Add the source files to your project. When you want to parse a string that you believe is in ISO 8601 date format, call [NSCalendarDate calendarDateWithString:myString]. The method will return either an NSCalendarDate or nil.
-
-HOW TO TEST THAT THIS CODE WORKS
-
-Type 'make test'. make will build the test program (testprog), then invoke test.sh.py to generate test.sh. Then make will invoke test.sh, which will invoke the test program with various dates.
-
-Alternatively, type 'make testprog', then invoke testprog yourself with any date you want to. If it doesn't give you the result you expected, contact me, making sure to provide me with both the input and the output.
-
-NOTES
-
-This version is 0.1.
-
-Whitespace before a date, and anything after a date, is ignored. Thus, " T23 and all's well" is a valid date for the purpose of this method. (Yes, T23 is a valid ISO 8601 date. It means 23:00:00, or 11 PM.)
-
-All of the frills of ISO 8601 are supported, except for extended dates (years longer than 4 digits). Specifically, you can use week-based dates (2006-W2 for the second week of 2006), ordinal dates (2006-365 for December 31), decimal minutes (11:30.5 == 11:30:30), and decimal seconds (11:30:10.5). All methods of specifying a time zone are supported.
-
-ISO 8601 leaves quite a bit up to the parties exchanging dates. I hope I've chosen reasonable defaults. For example (note that I'm writing this on 2006-02-24):
-
-• If the month or month and date are missing, 1 is assumed. "2006" == "2006-01-01".
-• If the year or year and month are missing, the current ones are assumed. "--02-01" == "2006-02-01". "---28" == "2006-02-28".
-• In the case of week-based dates, with the day missing, this implementation returns the first day of that week: 2006-W1 is 2006-01-01, 2006-W2 is 2006-01-08, etc.
-• For any date without a time, midnight on that date is used.
-• ISO 8601 permits the choice of either T0 or T24 for midnight. This implementation uses T0. T24 will get you T0 on the following day.
-• If no time-zone is specified, local time (as returned by [NSTimeZone localTimeZone]) is used.
-
-When a date is parsed that has a year but no century, this implementation adds the current century.
-
-The implementation is tolerant of out-of-range numbers. For example, "2005-13-40T24:62:89" == 1:02 AM on 2006-02-10. Notice that the month (13 > 12), date (40 > 31), hour (24 > 23), minute (62 > 59), and second (89 > 59) are all out-of-range.
-
-There is a "strict" mode that enforces sanity checks. In particular, the date must be the entire contents of the string, and numbers are range-checked. If you have any suggestions on how to make this mode more strict, contact me.
-
-BUGS
-
-• This method won't extract a date from just anywhere in a string, only immediately after the start of the string (or any leading whitespace). There are two solutions: either require that -calendarDateValue be invoked on a string that is only an ISO 8601 date, with nothing before or after (bad for parsing purposes), or find an ISO 8601 date as a substring. I won't do the first one, and barring a patch, I probably won't do the second one either.
-
-• Date ranges (also specified by ISO 8601) are not supported; this method will only return one date. To handle ranges would require at least one more method.
-
-• There is no method to analyze a date string and tell you what was found in it (year, month, week, day, ordinal day, etc.). Feel free to submit a patch.
-
-COPYRIGHT
-
-This code is copyright 2006 Peter Hosey. It is under the BSD license; see LICENSE.txt for the full text of the license.
View
@@ -1,155 +0,0 @@
-cc -std=c99 -c -o NSCalendarDate+ISO8601Parsing.o NSCalendarDate+ISO8601Parsing.m
-cc -framework Foundation testprog.o NSCalendarDate+ISO8601Parsing.o -o testprog
-./test.sh
-
-Tests with a date only:
-% ./testprog 2006-02-24 2006-12 2006 2006- 2006-02- 2006-0224 200602-24 20060224 2001-W1-1 2002-W1-1 2003-W1-1 2004-W1-1 2010-W1-1 2000-W1-1 2006-W1-1 2006-W1-2 2006-W02 2006-W2 2006-W02-01 2006-W02-1 2006-W2-01 2006-W2-1 2006-W2-2 2006-W2-8 2006-W3-1 2006-W22 2006-W22-11 06-02-24 06-12 06-02- 06-0224 0602-24 060224 06-W22 06-W2 06-W22-11 06-W2-1 -6-02-24 -6-12 -6 -6- -6-02- -6-0224 -602-24 -6-W22 -6-W2 -6-W22-11 -6-W2-1 --0224 --02-24 --2-24 --02-2 --02 ---24 -W2 -W2-11 -W-3 --W-3 2006-001 2006-002 2006-055 2006-365 2004-001 2004-366 -055 --055 2006T
-2006-02-24 → 2006-02-24 00:00:00 -0800
-2006-12 → 2006-12-01 00:00:00 -0800
-2006 → 2006-01-01 00:00:00 -0800
-2006- → 2006-01-01 00:00:00 -0800
-2006-02- → 2006-02-01 00:00:00 -0800
-2006-0224 → 2006-02-24 00:00:00 -0800
-200602-24 → 2020-06-02 00:00:00 -0700
-20060224 → 2006-02-24 00:00:00 -0800
-2001-W1-1 → 2001-01-01 00:00:00 -0800
-2002-W1-1 → 2001-12-31 00:00:00 -0800
-2003-W1-1 → 2002-12-30 00:00:00 -0800
-2004-W1-1 → 2003-12-29 00:00:00 -0800
-2010-W1-1 → 2010-01-04 00:00:00 -0800
-2000-W1-1 → 2000-01-03 00:00:00 -0800
-2006-W1-1 → 2006-01-02 00:00:00 -0800
-2006-W1-2 → 2006-01-03 00:00:00 -0800
-2006-W02 → 2006-01-09 00:00:00 -0800
-2006-W2 → 2006-01-09 00:00:00 -0800
-2006-W02-01 → 2006-01-09 00:00:00 -0800
-2006-W02-1 → 2006-01-09 00:00:00 -0800
-2006-W2-01 → 2006-01-09 00:00:00 -0800
-2006-W2-1 → 2006-01-09 00:00:00 -0800
-2006-W2-2 → 2006-01-10 00:00:00 -0800
-2006-W2-8 → 2006-01-16 00:00:00 -0800
-2006-W3-1 → 2006-01-16 00:00:00 -0800
-2006-W22 → 2006-05-29 00:00:00 -0700
-2006-W22-11 → 2006-06-08 00:00:00 -0700
-06-02-24 → 2006-02-24 00:00:00 -0800
-06-12 → 2006-12-01 00:00:00 -0800
-06-02- → 2006-02-01 00:00:00 -0800
-06-0224 → 2006-02-24 00:00:00 -0800
-0602-24 → 602-05-03 00:00:00 -0800
-060224 → 2006-02-24 00:00:00 -0800
-06-W22 → 2006-05-29 00:00:00 -0700
-06-W2 → 2006-01-09 00:00:00 -0800
-06-W22-11 → 2006-06-08 00:00:00 -0700
-06-W2-1 → 2006-01-09 00:00:00 -0800
--6-02-24 → 2006-02-01 00:00:00 -0800
--6-12 → 2006-12-01 00:00:00 -0800
--6 → 2006-01-01 00:00:00 -0800
--6- → 2006-01-01 00:00:00 -0800
--6-02- → 2006-02-01 00:00:00 -0800
--6-0224 → 2006-02-02 00:00:00 -0800
--602-24 → 2007-08-25 00:00:00 -0700
--6-W22 → 2006-02-01 02:00:00 -0800
--6-W2 → 2006-02-01 00:00:00 -0800
--6-W22-11 → 2006-02-01 02:00:00 -1100
--6-W2-1 → 2006-02-01 00:00:00 -0800
---0224 → 2006-02-24 00:00:00 -0800
---02-24 → 2006-02-24 00:00:00 -0800
---2-24 → 2006-02-24 00:00:00 -0800
---02-2 → 2006-02-02 00:00:00 -0800
---02 → 2006-01-31 00:00:00 -0800
----24 → 2006-05-24 00:00:00 -0700
--W2 → 2006-01-09 00:00:00 -0800
--W2-11 → 2006-01-19 00:00:00 -0800
--W-3 → 2006-01-04 00:00:00 -0800
---W-3 → 2006-01-04 00:00:00 -0800
-2006-001 → 2006-01-01 00:00:00 -0800
-2006-002 → 2006-01-02 00:00:00 -0800
-2006-055 → 2006-02-24 00:00:00 -0800
-2006-365 → 2006-12-31 00:00:00 -0800
-2004-001 → 2004-01-01 00:00:00 -0800
-2004-366 → 2004-12-31 00:00:00 -0800
--055 → 2006-02-24 00:00:00 -0800
---055 → 2006-02-24 00:00:00 -0800
-2006T → 2006-01-01 00:00:00 -0800
-
-Current year in x century:
-% ./testprog 20 1
-20 → 2006-01-01 00:00:00 -0800
-1 → 106-01-01 00:00:00 -0800
-
-x year in current century:
-% ./testprog -06
--06 → 2006-01-02 00:00:00 -0800
-
-x year and month in current century:
-% ./testprog -06-02
--06-02 → 2006-02-01 00:00:00 -0800
-
-x year, month, and date in current century:
-% ./testprog 06-02-24
-06-02-24 → 2006-02-24 00:00:00 -0800
-
-x month and date in current year:
-% ./testprog --02-24
---02-24 → 2006-02-24 00:00:00 -0800
-
-x date in current year and month:
-% ./testprog ---24
----24 → 2006-05-24 00:00:00 -0700
-
-Tests with a time only:
-% ./testprog T22:63:24-11:21 T22:63:24+50:70 T22:1:2 T22:1Z T22: T22 T2 T2:2:2
-T22:63:24-11:21 → 2006-05-29 23:03:24 -1121
-T22:63:24+50:70 → 2006-05-29 23:03:24 -0700
-T22:1:2 → 2006-05-29 22:01:02 -0700
-T22:1Z → 2006-05-29 22:01:00 +0000
-T22: → 2006-05-29 22:00:00 -0700
-T22 → 2006-05-29 22:00:00 -0700
-T2 → 2006-05-29 02:00:00 -0700
-T2:2:2 → 2006-05-29 02:02:02 -0700
-
-Tests with both a date and a time:
-% ./testprog 2006-02-24T02:43:24 2006-02-24T22:43:24 2006-02-24T22:63:24 2006-12T12:34 2006T22
-2006-02-24T02:43:24 → 2006-02-24 02:43:24 -0800
-2006-02-24T22:43:24 → 2006-02-24 22:43:24 -0800
-2006-02-24T22:63:24 → 2006-02-24 23:03:24 -0800
-2006-12T12:34 → 2006-12-01 12:34:00 -0800
-2006T22 → 2006-01-01 22:00:00 -0800
-
-Tests with a date, a time, and a time zone:
-% ./testprog 2006-02-24T22:63:24-01:00 2006-02-24T22:63:24Z 2006-02-24T22:63:24-1 2006-02-24T22:63:24-01 2006-02-24T22:63:24-01:32 2006-02-24T22:63:24-01:0 2006-02-24T22:63:24-01:00 2006-02-24T22:63:24-01:01 2006-02-24T22:63:24-01:11 2006-02-24T22:63:24-11:21
-2006-02-24T22:63:24-01:00 → 2006-02-24 23:03:24 -0100
-2006-02-24T22:63:24Z → 2006-02-24 23:03:24 +0000
-2006-02-24T22:63:24-1 → 2006-02-24 23:03:24 -0100
-2006-02-24T22:63:24-01 → 2006-02-24 23:03:24 -0100
-2006-02-24T22:63:24-01:32 → 2006-02-24 23:03:24 -0132
-2006-02-24T22:63:24-01:0 → 2006-02-24 23:03:24 -0100
-2006-02-24T22:63:24-01:00 → 2006-02-24 23:03:24 -0100
-2006-02-24T22:63:24-01:01 → 2006-02-24 23:03:24 -0101
-2006-02-24T22:63:24-01:11 → 2006-02-24 23:03:24 -0111
-2006-02-24T22:63:24-11:21 → 2006-02-24 23:03:24 -1121
-
-Invalid dates:
-% ./testprog T 2006-W 2006-366 2006-400 2004-367 -2006-02-24T02:43:24 -2006-02-24T22:43:24 -2006-02-24T22:63:24 -2006-12T12:34 -2006T22 -60224 --2006-02-24T02:43:24 --2006-02-24T22:43:24 --2006-02-24T22:63:24 --2006-12T12:34 --2006T22 ---2006-02-24T02:43:24 ---2006-02-24T22:43:24 ---2006-02-24T22:63:24 ---2006-12T12:34 ---2006T22
- → (null)
-T → (null)
-2006-W → 2006-01-01 00:00:00 -0800
-2006-366 → 2007-01-01 00:00:00 -0800
-2006-400 → 2007-02-04 00:00:00 -0800
-2004-367 → 2005-01-01 00:00:00 -0800
--2006-02-24T02:43:24 → 20-06-02 00:00:00 -0800
--2006-02-24T22:43:24 → 20-06-02 00:00:00 -0800
--2006-02-24T22:63:24 → 20-06-02 00:00:00 -0800
--2006-12T12:34 → 20-06-12 12:34:00 -0800
--2006T22 → 20-06-01 22:00:00 -0800
--60224 → (null)
---2006-02-24T02:43:24 → 2006-09-08 00:00:00 -0700
---2006-02-24T22:43:24 → 2006-09-08 00:00:00 -0700
---2006-02-24T22:63:24 → 2006-09-08 00:00:00 -0700
---2006-12T12:34 → 2006-09-08 00:00:00 -0700
---2006T22 → 2006-09-08 22:00:00 -0700
----2006-02-24T02:43:24 → (null)
----2006-02-24T22:43:24 → (null)
----2006-02-24T22:63:24 → (null)
----2006-12T12:34 → (null)
----2006T22 → (null)
View
@@ -1,67 +0,0 @@
-#!/bin/sh
-
-echo
-echo 'Tests with a date only:'
-
-echo '% ./testprog 2006-02-24 2006-12 2006 2006- 2006-02- 2006-0224 200602-24 20060224 2001-W1-1 2002-W1-1 2003-W1-1 2004-W1-1 2010-W1-1 2000-W1-1 2006-W1-1 2006-W1-2 2006-W02 2006-W2 2006-W02-01 2006-W02-1 2006-W2-01 2006-W2-1 2006-W2-2 2006-W2-8 2006-W3-1 2006-W22 2006-W22-11 06-02-24 06-12 06-02- 06-0224 0602-24 060224 06-W22 06-W2 06-W22-11 06-W2-1 -6-02-24 -6-12 -6 -6- -6-02- -6-0224 -602-24 -6-W22 -6-W2 -6-W22-11 -6-W2-1 --0224 --02-24 --2-24 --02-2 --02 ---24 -W2 -W2-11 -W-3 --W-3 2006-001 2006-002 2006-055 2006-365 2004-001 2004-366 -055 --055 2006T'
-./testprog 2006-02-24 2006-12 2006 2006- 2006-02- 2006-0224 200602-24 20060224 2001-W1-1 2002-W1-1 2003-W1-1 2004-W1-1 2010-W1-1 2000-W1-1 2006-W1-1 2006-W1-2 2006-W02 2006-W2 2006-W02-01 2006-W02-1 2006-W2-01 2006-W2-1 2006-W2-2 2006-W2-8 2006-W3-1 2006-W22 2006-W22-11 06-02-24 06-12 06-02- 06-0224 0602-24 060224 06-W22 06-W2 06-W22-11 06-W2-1 -6-02-24 -6-12 -6 -6- -6-02- -6-0224 -602-24 -6-W22 -6-W2 -6-W22-11 -6-W2-1 --0224 --02-24 --2-24 --02-2 --02 ---24 -W2 -W2-11 -W-3 --W-3 2006-001 2006-002 2006-055 2006-365 2004-001 2004-366 -055 --055 2006T
-
-echo
-echo 'Current year in x century:'
-
-echo '% ./testprog 20 1'
-./testprog 20 1
-
-echo
-echo 'x year in current century:'
-
-echo '% ./testprog -06'
-./testprog -06
-
-echo
-echo 'x year and month in current century:'
-
-echo '% ./testprog -06-02'
-./testprog -06-02
-
-echo
-echo 'x year, month, and date in current century:'
-
-echo '% ./testprog 06-02-24'
-./testprog 06-02-24
-
-echo
-echo 'x month and date in current year:'
-
-echo '% ./testprog --02-24'
-./testprog --02-24
-
-echo
-echo 'x date in current year and month:'
-
-echo '% ./testprog ---24'
-./testprog ---24
-
-echo
-echo 'Tests with a time only:'
-
-echo '% ./testprog T22:63:24-11:21 T22:63:24+50:70 T22:1:2 T22:1Z T22: T22 T2 T2:2:2'
-./testprog T22:63:24-11:21 T22:63:24+50:70 T22:1:2 T22:1Z T22: T22 T2 T2:2:2
-
-echo
-echo 'Tests with both a date and a time:'
-
-echo '% ./testprog 2006-02-24T02:43:24 2006-02-24T22:43:24 2006-02-24T22:63:24 2006-12T12:34 2006T22'
-./testprog 2006-02-24T02:43:24 2006-02-24T22:43:24 2006-02-24T22:63:24 2006-12T12:34 2006T22
-
-echo
-echo 'Tests with a date, a time, and a time zone:'
-
-echo '% ./testprog 2006-02-24T22:63:24-01:00 2006-02-24T22:63:24Z 2006-02-24T22:63:24-1 2006-02-24T22:63:24-01 2006-02-24T22:63:24-01:32 2006-02-24T22:63:24-01:0 2006-02-24T22:63:24-01:00 2006-02-24T22:63:24-01:01 2006-02-24T22:63:24-01:11 2006-02-24T22:63:24-11:21'
-./testprog 2006-02-24T22:63:24-01:00 2006-02-24T22:63:24Z 2006-02-24T22:63:24-1 2006-02-24T22:63:24-01 2006-02-24T22:63:24-01:32 2006-02-24T22:63:24-01:0 2006-02-24T22:63:24-01:00 2006-02-24T22:63:24-01:01 2006-02-24T22:63:24-01:11 2006-02-24T22:63:24-11:21
-
-echo
-echo 'Invalid dates:'
-
-echo '% ./testprog '' T 2006-W 2006-366 2006-400 2004-367 -2006-02-24T02:43:24 -2006-02-24T22:43:24 -2006-02-24T22:63:24 -2006-12T12:34 -2006T22 -60224 --2006-02-24T02:43:24 --2006-02-24T22:43:24 --2006-02-24T22:63:24 --2006-12T12:34 --2006T22 ---2006-02-24T02:43:24 ---2006-02-24T22:43:24 ---2006-02-24T22:63:24 ---2006-12T12:34 ---2006T22'
-./testprog '' T 2006-W 2006-366 2006-400 2004-367 -2006-02-24T02:43:24 -2006-02-24T22:43:24 -2006-02-24T22:63:24 -2006-12T12:34 -2006T22 -60224 --2006-02-24T02:43:24 --2006-02-24T22:43:24 --2006-02-24T22:63:24 --2006-12T12:34 --2006T22 ---2006-02-24T02:43:24 ---2006-02-24T22:43:24 ---2006-02-24T22:63:24 ---2006-12T12:34 ---2006T22
Oops, something went wrong.

0 comments on commit d14d9ab

Please sign in to comment.