diff --git a/.forgejo/workflows/test.yaml b/.forgejo/workflows/test.yaml index e79a7f2..ee717ed 100644 --- a/.forgejo/workflows/test.yaml +++ b/.forgejo/workflows/test.yaml @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +# SPDX-License-Identifier: MIT + # Runs the test suite on every push, and publishes the API documentation # to https://jeff.ocj.page/zig-datetime/ when the push was to main. # @@ -30,6 +33,9 @@ jobs: - name: Check formatting run: nix develop .#default -c zig fmt --check . + - name: Check REUSE compliance + run: nix develop .#default -c reuse lint + - name: Run tests run: nix develop .#default -c zig build test diff --git a/.forgejo/workflows/tzdata.yml b/.forgejo/workflows/tzdata.yml index f355b8c..3c507a2 100644 --- a/.forgejo/workflows/tzdata.yml +++ b/.forgejo/workflows/tzdata.yml @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +# SPDX-License-Identifier: MIT + # Watches for new IANA timezone database releases and opens a pull request # pinning each one. # diff --git a/.gitignore b/.gitignore index 42979e4..64c7972 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +# SPDX-License-Identifier: MIT + /.zig-cache /zig-out /result* diff --git a/LICENSES/CC0-1.0.txt b/LICENSES/CC0-1.0.txt new file mode 100644 index 0000000..0e259d4 --- /dev/null +++ b/LICENSES/CC0-1.0.txt @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt new file mode 100644 index 0000000..a348e30 --- /dev/null +++ b/LICENSES/MIT.txt @@ -0,0 +1,20 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index aa3b023..6c30317 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ + + # zig-datetime Dates, times, and timezones for Zig 0.16. diff --git a/REUSE.toml b/REUSE.toml new file mode 100644 index 0000000..6b8f0a8 --- /dev/null +++ b/REUSE.toml @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +# SPDX-License-Identifier: MIT + +version = 1 +SPDX-PackageName = "zig-datetime" +SPDX-PackageSupplier = "Jeffrey C. Ollie " +SPDX-PackageDownloadLocation = "git+https://git.ocjtech.us/jeff/zig-datetime.git" + +# flake.lock is generated JSON, which has no comment syntax to carry a header. +# It is dedicated to the public domain under CC0-1.0 rather than carrying the +# project's MIT, so that pinning this flake creates no attribution obligation +# and no rights are asserted over generated content. +[[annotations]] +path = "flake.lock" +precedence = "aggregate" +SPDX-FileCopyrightText = "NONE" +SPDX-License-Identifier = "CC0-1.0" diff --git a/build.zig b/build.zig index d04f5ec..7169db8 100644 --- a/build.zig +++ b/build.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + const std = @import("std"); /// The IANA release that `build.zig.zon` pins. Kept here so the generated diff --git a/build.zig.zon b/build.zig.zon index beade02..ac43fce 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + .{ .name = .datetime, .version = "0.0.1", @@ -26,6 +29,8 @@ "build.zig", "build.zig.zon", "README.md", + "LICENSES", + "REUSE.toml", "src", "tools", }, diff --git a/flake.nix b/flake.nix index 5946784..43e5a18 100644 --- a/flake.nix +++ b/flake.nix @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +# SPDX-License-Identifier: MIT + { description = "zig-datetime"; @@ -45,6 +48,8 @@ # Publishes the API documentation to ocj.page; see # .forgejo/workflows/test.yaml. pkgs.git-pages-cli + # Checks the SPDX headers; see REUSE.toml. + pkgs.reuse ]; }; } diff --git a/src/Date.zig b/src/Date.zig index c653378..3275f41 100644 --- a/src/Date.zig +++ b/src/Date.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + const Date = @This(); const std = @import("std"); diff --git a/src/DateTime.zig b/src/DateTime.zig index 6db46a1..2b4eca3 100644 --- a/src/DateTime.zig +++ b/src/DateTime.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + const DateTime = @This(); const std = @import("std"); diff --git a/src/Instant.zig b/src/Instant.zig index 9056708..1bbfd87 100644 --- a/src/Instant.zig +++ b/src/Instant.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + const Instant = @This(); const std = @import("std"); diff --git a/src/TimeZone.zig b/src/TimeZone.zig index 7796920..1560789 100644 --- a/src/TimeZone.zig +++ b/src/TimeZone.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + //! A timezone: the rules that say what a clock in some place reads at a //! given instant, and what that reading is called. //! diff --git a/src/bench.zig b/src/bench.zig index 249749a..24ca83c 100644 --- a/src/bench.zig +++ b/src/bench.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + //! Benchmarks for the datetime library, run with `zig build bench`. //! //! Inputs cycle through a table of 1024 values and every result is folded diff --git a/src/datetime.zig b/src/datetime.zig index d547e28..e510b75 100644 --- a/src/datetime.zig +++ b/src/datetime.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + const std = @import("std"); pub const Year = @import("year.zig").Year; diff --git a/src/day.zig b/src/day.zig index 6d57d9b..3a16521 100644 --- a/src/day.zig +++ b/src/day.zig @@ -1 +1,4 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + pub const Day = u6; diff --git a/src/dayofweek.zig b/src/dayofweek.zig index 5007a3e..5db5cfd 100644 --- a/src/dayofweek.zig +++ b/src/dayofweek.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + const std = @import("std"); const log = std.log.scoped(.day_of_week); diff --git a/src/formatsequence.zig b/src/formatsequence.zig index 44556fb..bcb38c8 100644 --- a/src/formatsequence.zig +++ b/src/formatsequence.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + const std = @import("std"); pub const FormatTag = enum { diff --git a/src/hour.zig b/src/hour.zig index 53d2567..126e997 100644 --- a/src/hour.zig +++ b/src/hour.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + const std = @import("std"); pub const Hour = std.math.IntFittingRange(0, 24); diff --git a/src/iso8601.zig b/src/iso8601.zig index 1d5e8b7..cb3ce98 100644 --- a/src/iso8601.zig +++ b/src/iso8601.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + //! Parser for the date and time representations of ISO 8601, the format //! behind `2024-03-15T14:30:00Z` and its many relatives. RFC 3339, which //! is what most internet protocols actually mean by "ISO 8601", is the diff --git a/src/leap.zig b/src/leap.zig index f3a8cde..a09dc98 100644 --- a/src/leap.zig +++ b/src/leap.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + const Year = @import("year.zig").Year; /// Returns true if `year` is a leap year in the proleptic Gregorian calendar. diff --git a/src/minute.zig b/src/minute.zig index 139614f..9c4df2c 100644 --- a/src/minute.zig +++ b/src/minute.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + const std = @import("std"); pub const Minute = std.math.IntFittingRange(0, 60); diff --git a/src/month.zig b/src/month.zig index e750676..251035c 100644 --- a/src/month.zig +++ b/src/month.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + const std = @import("std"); const Year = @import("year.zig").Year; diff --git a/src/nanosecond.zig b/src/nanosecond.zig index 592a3c6..263cb77 100644 --- a/src/nanosecond.zig +++ b/src/nanosecond.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + const std = @import("std"); pub const Nanosecond = std.math.IntFittingRange(0, std.time.ns_per_s); diff --git a/src/ordinal.zig b/src/ordinal.zig index 2e6f306..77780dc 100644 --- a/src/ordinal.zig +++ b/src/ordinal.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + const std = @import("std"); /// Byte-for-byte string equality, used as the map's comparison function. diff --git a/src/posixtz.zig b/src/posixtz.zig index a711fbb..8930310 100644 --- a/src/posixtz.zig +++ b/src/posixtz.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + //! Parser and evaluator for the POSIX `TZ` string, the rule that appears in //! the footer of a version 2 or later TZif file and that also shows up in //! the `TZ` environment variable. diff --git a/src/print.zig b/src/print.zig index 0af0f52..147e330 100644 --- a/src/print.zig +++ b/src/print.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + const std = @import("std"); // pub fn Ordinal(style: enum {.normal, .superscript}) type { diff --git a/src/read.zig b/src/read.zig index 91204fa..db330b7 100644 --- a/src/read.zig +++ b/src/read.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + const std = @import("std"); const log = std.log.scoped(.read); const Nanosecond = @import("nanosecond.zig").Nanosecond; diff --git a/src/rfc822.zig b/src/rfc822.zig index f9c6611..965d11f 100644 --- a/src/rfc822.zig +++ b/src/rfc822.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + //! Parsing of the date and time syntax defined by RFC 822 section 5, as //! amended by RFC 1123 section 5.2.14 (four digit years) and RFC 5322 //! sections 3.3 and 4.3 (obsolete forms). This is the format used by diff --git a/src/second.zig b/src/second.zig index e4750d6..c68a6ff 100644 --- a/src/second.zig +++ b/src/second.zig @@ -1 +1,4 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + pub const Second = u6; diff --git a/src/si.zig b/src/si.zig index 75e1ec6..b2af24e 100644 --- a/src/si.zig +++ b/src/si.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + // https://www.nist.gov/pml/owm/metric-si-prefixes const std = @import("std"); diff --git a/src/tzdata/stub.zig b/src/tzdata/stub.zig index 749a3f2..6673a08 100644 --- a/src/tzdata/stub.zig +++ b/src/tzdata/stub.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + //! Stands in for the generated timezone database when the build was //! configured without embedded data. Building with `-Dembed-tzdata` swaps //! this out for a module generated from the IANA sources; see `build.zig`. diff --git a/src/tzdb.zig b/src/tzdb.zig index 01d3666..36019c0 100644 --- a/src/tzdb.zig +++ b/src/tzdb.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + //! Sources of timezone data. //! //! `system` reads the operating system's copy of the IANA database, the diff --git a/src/tzif.zig b/src/tzif.zig index 465e587..5fb0093 100644 --- a/src/tzif.zig +++ b/src/tzif.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + //! Reader for the Time Zone Information Format (TZif) defined by RFC 8536, //! the binary format that the IANA timezone database is compiled into and //! that operating systems keep under `/usr/share/zoneinfo`. diff --git a/src/year.zig b/src/year.zig index 62358c9..81b3305 100644 --- a/src/year.zig +++ b/src/year.zig @@ -1 +1,4 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + pub const Year = i32; diff --git a/tools/tzpack.zig b/tools/tzpack.zig index d629a0d..2229a32 100644 --- a/tools/tzpack.zig +++ b/tools/tzpack.zig @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +// SPDX-License-Identifier: MIT + //! Packs a tree of TZif files, as produced by `zic -d`, into the two files //! that give the library its embedded timezone database: `tzdata.bin`, //! holding every zone's bytes end to end, and `tzdata.zig`, an index of diff --git a/tools/update-tzdata.sh b/tools/update-tzdata.sh index de012e3..2d35c6c 100755 --- a/tools/update-tzdata.sh +++ b/tools/update-tzdata.sh @@ -1,4 +1,6 @@ #!/usr/bin/env bash +# SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie +# SPDX-License-Identifier: MIT # # Updates the pinned IANA timezone database release. #