From 7767e5e56197384df3efdaa0ccd9d5b3a7c69056 Mon Sep 17 00:00:00 2001 From: Miraty Date: Tue, 21 Feb 2023 15:33:12 +0100 Subject: [PATCH] Second commit --- .gitignore | 3 +- CNPL-NAv7.md | 440 +++++++++++++++++++++++++++++++++ Cargo.lock | 248 ------------------- Cargo.toml | 10 +- PKGBUILD | 16 +- README.md | 2 +- UNLICENSE | 22 -- dit/Cargo.toml | 9 + dit/src/main.rs | 30 +++ libdit/Cargo.toml | 6 + libdit/src/lib.rs | 50 ++++ libdit/tests/libdit.rs | 9 + libstardit/Cargo.toml | 8 + libstardit/src/lib.rs | 38 +++ libstardit/tests/libstardit.rs | 25 ++ src/main.rs | 49 ---- stardit/Cargo.toml | 8 + stardit/src/main.rs | 56 +++++ 18 files changed, 695 insertions(+), 334 deletions(-) create mode 100644 CNPL-NAv7.md delete mode 100644 Cargo.lock delete mode 100644 UNLICENSE create mode 100644 dit/Cargo.toml create mode 100644 dit/src/main.rs create mode 100644 libdit/Cargo.toml create mode 100644 libdit/src/lib.rs create mode 100644 libdit/tests/libdit.rs create mode 100644 libstardit/Cargo.toml create mode 100644 libstardit/src/lib.rs create mode 100644 libstardit/tests/libstardit.rs delete mode 100644 src/main.rs create mode 100644 stardit/Cargo.toml create mode 100644 stardit/src/main.rs diff --git a/.gitignore b/.gitignore index 65ee9a7..6cae294 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -/target +target /*.tar.zst +Cargo.lock diff --git a/CNPL-NAv7.md b/CNPL-NAv7.md new file mode 100644 index 0000000..0238793 --- /dev/null +++ b/CNPL-NAv7.md @@ -0,0 +1,440 @@ +THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS +COOPERATIVE NON-VIOLENT PUBLIC LICENSE (\"LICENSE\"). THE WORK IS +PROTECTED BY COPYRIGHT AND ALL OTHER APPLICABLE LAWS. ANY USE OF THE +WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS +PROHIBITED. BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED IN THIS +LICENSE, YOU AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE +EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR +GRANTS YOU THE RIGHTS CONTAINED HERE IN AS CONSIDERATION FOR ACCEPTING +THE TERMS AND CONDITIONS OF THIS LICENSE AND FOR AGREEING TO BE BOUND BY +THE TERMS AND CONDITIONS OF THIS LICENSE. + +# Definitions + +An Act of War is any action of one country against any group either with +an intention to provoke a conflict or an action that occurs during a +declared war or during armed conflict between military forces of any +origin. This includes but is not limited to enforcing sanctions or +sieges, supplying armed forces, or profiting from the manufacture of +tools or weaponry used in military conflict. + +An Adaptation is a work based upon the Work, or upon the Work and other +pre-existing works, such as a translation, adaptation, derivative work, +arrangement of music or other alterations of a literary or artistic +work, or phonogram or performance and includes cinematographic +adaptations or any other form in which the Work may be recast, +transformed, or adapted including in any form recognizably derived from +the original, except that a work that constitutes a Collection will not +be considered an Adaptation for the purpose of this License. For the +avoidance of doubt, where the Work is a musical work, performance or +phonogram, the synchronization of the Work in timed-relation with a +moving image (\"synching\") will be considered an Adaptation for the +purpose of this License. In addition, where the Work is designed to +output a neural network the output of the neural network will be +considered an Adaptation for the purpose of this license. + +Bodily Harm is any physical hurt or injury to a person that interferes +with the health or comfort of the person and that is more than merely +transient or trifling in nature. + +Distribute is to make available to the public the original and copies of +the Work or Adaptation, as appropriate, through sale, gift or any other +transfer of possession or ownership. + +Incarceration is Confinement in a jail, prison, or any other place where +individuals of any kind are held against either their will or (if their +will cannot be determined) the will of their legal guardian or +guardians. In the case of a conflict between the will of the individual +and the will of their legal guardian or guardians, the will of the +individual will take precedence. + +Licensor is The individual, individuals, entity, or entities that +offer(s) the Work under the terms of this License + +Original Author is in the case of a literary or artistic work, the +individual, individuals, entity or entities who created the Work or if +no individual or entity can be identified, the publisher; and in +addition + +- in the case of a performance the actors, singers, musicians, + dancers, and other persons who act, sing, deliver, declaim, play in, + interpret or otherwise perform literary or artistic works or + expressions of folklore; + +- in the case of a phonogram the producer being the person or legal + entity who first fixes the sounds of a performance or other sounds; + and, + +- in the case of broadcasts, the organization that transmits the + broadcast. + +Work is the literary and/or artistic work offered under the terms of +this License including without limitation any production in the +literary, scientific and artistic domain, whatever may be the mode or +form of its expression including digital form, such as a book, pamphlet +and other writing; a lecture, address, sermon or other work of the same +nature; a dramatic or dramatico-musical work; a choreographic work or +entertainment in dumb show; a musical composition with or without words; +a cinematographic work to which are assimilated works expressed by a +process analogous to cinematography; a work of drawing, painting, +architecture, sculpture, engraving or lithography; a photographic work +to which are assimilated works expressed by a process analogous to +photography; a work of applied art; an illustration, map, plan, sketch +or three-dimensional work relative to geography, topography, +architecture or science; a performance; a broadcast; a phonogram; a +compilation of data to the extent it is protected as a copyrightable +work; or a work performed by a variety or circus performer to the extent +it is not otherwise considered a literary or artistic work. + +You means an individual or entity exercising rights under this License +who has not previously violated the terms of this License with respect +to the Work, or who has received express permission from the Licensor to +exercise rights under this License despite a previous violation. + +Publicly Perform means to perform public recitations of the Work and to +communicate to the public those public recitations, by any means or +process, including by wire or wireless means or public digital +performances; to make available to the public Works in such a way that +members of the public may access these Works from a place and at a place +individually chosen by them; to perform the Work to the public by any +means or process and the communication to the public of the performances +of the Work, including by public digital performance; to broadcast and +rebroadcast the Work by any means including signs, sounds or images. + +Reproduce is to make copies of the Work by any means including without +limitation by sound or visual recordings and the right of fixation and +reproducing fixations of the Work, including storage of a protected +performance or phonogram in digital form or other electronic medium. + +Software is any digital Work which, through use of a third-party piece +of Software or through the direct usage of itself on a computer system, +the memory of the computer is modified dynamically or semi-dynamically. +\"Software\", secondly, processes or interprets information. + +Source Code is Any digital Work which, through use of a third-party +piece of Software or through the direct usage of itself on a computer +system, the memory of the computer is modified dynamically or +semi-dynamically. \"Software\", secondly, processes or interprets +information. + +Surveilling is the use of the Work to either overtly or covertly observe +and record persons and or their activities. + +A Network Service is the use of a piece of Software to interpret or +modify information that is subsequently and directly served to users +over the Internet. + +To Discriminate is use of a work to differentiate between humans in a +such a way which prioritizes some above others on the basis of percieved +membership within certain groups. + +Hate Speech is Communication or any form of expression which is solely +for the purpose of expressing hatred for some group or advocating a form +of Discrimination between humans. + +Coercion is leveraging of the threat of force or use of force to +intimidate a person in order to gain compliance, or to offer large +incentives which aim to entice a person to act against their will. + +# Fair Dealing Rights + +Nothing in this License is intended to reduce, limit, or restrict any +uses free from copyright or rights arising from limitations or +exceptions that are provided for in connection with the copyright +protection under copyright law or other applicable laws. + +# License Grant + +Subject to the terms and conditions of this License, Licensor hereby +grants You a worldwide, royalty-free, non-exclusive, perpetual (for the +duration of the applicable copyright) license to exercise the rights in +the Work as stated below: + +To Reproduce the Work, to incorporate the Work into one or more +Collections, and to Reproduce the Work as incorporated in the +Collections + +To create and Reproduce Adaptations provided that any such Adaptation, +including any translation in any medium, takes reasonable steps to +clearly label, demarcate or otherwise identify that changes were made to +the original Work. For example, a translation could be marked \"The +original work was translated from English to Spanish,\" or a +modification could indicate \"The original work has been modified.\" + +To Distribute and Publicly Perform the Work including as incorporated in +Collections. + +To Distribute and Publicly Perform Adaptations. The above rights may be +exercised in all media and formats whether now known or hereafter +devised. The above rights include the right to make such modifications +as are technically necessary to exercise the rights in other media and +formats. This License constitutes the entire agreement between the +parties with respect to the Work licensed here. There are no +understandings, agreements or representations with respect to the Work +not specified here. Licensor shall not be bound by any additional +provisions that may appear in any communication from You. This License +may not be modified without the mutual written agreement of the Licensor +and You. All rights not expressly granted by Licensor are hereby +reserved, including but not limited to the rights set forth in +Non-waivable Compulsory License Schemes, Waivable Compulsory License +Schemes, and Voluntary License Schemes in the restrictions. + +# Restrictions + +The license granted in the license grant above is expressly made subject +to and limited by the following restrictions: + +You may Distribute or Publicly Perform the Work only under the terms of +this License. You must include a copy of, or the Uniform Resource +Identifier (URI) for, this License with every copy of the Work You +Distribute or Publicly Perform. You may not offer or impose any terms on +the Work that restrict the terms of this License or the ability of the +recipient of the Work to exercise the rights granted to that recipient +under the terms of the License. You may not sublicense the Work. You +must keep intact all notices that refer to this License and to the +disclaimer of warranties with every copy of the Work You Distribute or +Publicly Perform. When You Distribute or Publicly Perform the Work, You +may not impose any effective technological measures on the Work that +restrict the ability of a recipient of the Work from You to exercise the +rights granted to that recipient under the terms of the License. This +Section applies to the Work as incorporated in a Collection, but this +does not require the Collection apart from the Work itself to be made +subject to the terms of this License. If You create a Collection, upon +notice from any Licensor You must, to the extent practicable, remove +from the Collection any credit as requested. If You create an +Adaptation, upon notice from any Licensor You must, to the extent +practicable, remove from the Adaptation any credit as requested. + +## Commercial Restrictions + +You may not exercise any of the rights granted to You in the above +section in any manner that is primarily intended for or directed toward +commercial advantage or private monetary compensation unless you meet +the following requirements. + +i. You are a worker-owned business or worker-owned collective. + +ii. after tax, all financial gain, surplus, profits and benefits + produced by the business or collective are distributed among the + worker-owners unless a set amount is to be allocated towards + community projects as decided by a previously-established consensus + agreement between the worker-owners where all worker-owners agreed. + +iii. You are not using such rights on behalf of a business other than + those specified in (i) or (ii) above, nor are using such rights as + a proxy on behalf of a business with the intent to circumvent the + aforementioned restrictions on such a business. + +The exchange of the Work for other copyrighted works by means of digital +file-sharing or otherwise shall not be considered to be intended for or +directed toward commercial advantage or private monetary compensation, +provided there is no payment of any monetary compensation in connection +with the exchange of copyrighted works. + +If the Work meets the definition of Software, You may exercise the +rights granted in the license grant only if You provide a copy of the +corresponding Source Code from which the Work was derived in digital +form, or You provide a URI for the corresponding Source Code of the +Work, to any recipients upon request. + +If the Work is used as or for a Network Service, You may exercise the +rights granted in the license grant only if You provide a copy of the +corresponding Source Code from which the Work was derived in digital +form, or You provide a URI for the corresponding Source Code to the +Work, to any recipients of the data served or modified by the Web +Service. + +Any use by a business that is privately owned and managed, and that +seeks to generate profit from the labor of employees paid by salary or +other wages, is not permitted under this license. + +## + +You may exercise the rights granted in the license grant for any +purposes only if: + +i. You do not use the Work for the purpose of inflicting Bodily Harm on + human beings (subject to criminal prosecution or otherwise) outside + of providing medical aid or undergoing a voluntary procedure under + no form of Coercion. + +ii. You do not use the Work for the purpose of Surveilling or tracking + individuals for financial gain. + +iii. You do not use the Work in an Act of War. + +iv. You do not use the Work for the purpose of supporting or profiting + from an Act of War. + +v. You do not use the Work for the purpose of Incarceration. + +vi. You do not use the Work for the purpose of extracting, processing, + or refining, oil, gas, or coal. Or to in any other way to + deliberately pollute the environment as a byproduct of manufacturing + or irresponsible disposal of hazardous materials. + +vii. You do not use the Work for the purpose of expediting, + coordinating, or facilitating paid work undertaken by individuals + under the age of 12 years. + +viii. You do not use the Work to either Discriminate or spread Hate + Speech on the basis of sex, sexual orientation, gender identity, + race, age, disability, color, national origin, religion, caste, or + lower economic status. + +Non-waivable Compulsory License Schemes. In those jurisdictions in which +the right to collect royalties through any statutory or compulsory +licensing scheme cannot be waived, the Licensor reserves the exclusive +right to collect such royalties for any exercise by You of the rights +granted under this License + +Waivable Compulsory License Schemes. In those jurisdictions in which the +right to collect royalties through any statutory or compulsory licensing +scheme can be waived, the Licensor reserves the exclusive right to +collect such royalties for any exercise by You of the rights granted +under this License if Your exercise of such rights is for a purpose or +use which is otherwise than noncommercial as permitted under Commercial +Restrictions and otherwise waives the right to collect royalties through +any statutory or compulsory licensing scheme. + +Voluntary License Schemes. The Licensor reserves the right to collect +royalties, whether individually or, in the event that the Licensor is a +member of a collecting society that administers voluntary licensing +schemes, via that society, from any exercise by You of the rights +granted under this License that is for a purpose or use which is +otherwise than noncommercial as permitted under the license grant. + +Except as otherwise agreed in writing by the Licensor or as may be +otherwise permitted by applicable law, if You Reproduce, Distribute or +Publicly Perform the Work either by itself or as part of any Adaptations +or Collections, You must not distort, mutilate, modify or take other +derogatory action in relation to the Work which would be prejudicial to +the Original Author\'s honor or reputation. Licensor agrees that in +those jurisdictions (e.g. Japan), in which any exercise of the right +granted in the license grant of this License (the right to make +Adaptations) would be deemed to be a distortion, mutilation, +modification or other derogatory action prejudicial to the Original +Author\'s honor and reputation, the Licensor will waive or not assert, +as appropriate, this Section, to the fullest extent permitted by the +applicable national law, to enable You to reasonably exercise Your right +under the license grant of this License (right to make Adaptations) but +not otherwise. + +Do not make any legal claim against anyone accusing the Work, with or +without changes, alone or with other works, of infringing any patent +claim. + +# Representations Warranties and Disclaimer + +UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR +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, MERCHANTIBILITY, +FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF +LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, +WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE +EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. + +# Limitation on Liability + +EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL +LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, +INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF +THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED +OF THE POSSIBILITY OF SUCH DAMAGES. + +# Termination + +This License and the rights granted hereunder will terminate +automatically upon any breach by You of the terms of this License. +Individuals or entities who have received Adaptations or Collections +from You under this License, however, will not have their licenses +terminated provided such individuals or entities remain in full +compliance with those licenses. The Sections on definitions, fair +dealing rights, representations, warranties, and disclaimer, limitation +on liability, termination, and revised license versions will survive any +termination of this License. + +Subject to the above terms and conditions, the license granted here is +perpetual (for the duration of the applicable copyright in the Work). +Notwithstanding the above, Licensor reserves the right to release the +Work under different license terms or to stop distributing the Work at +any time; provided, however that any such election will not serve to +withdraw this License (or any other license that has been, or is +required to be, granted under the terms of this License), and this +License will continue in full force and effect unless terminated as +stated above. + +# Revised License Versions + +This License may receive future revisions in the original spirit of the +license intended to strengthen This License. Each version of This +License has an incrementing version number. + +Unless otherwise specified like in the below subsection The Licensor has +only granted this current version of This License for The Work. In this +case future revisions do not apply. + +The Licensor may specify that the latest available revision of This +License be used for The Work by either explicitly writing so or by +suffixing the License URI with a \"+\" symbol. + +The Licensor may specify that The Work is also available under the terms +of This License\'s current revision as well as specific future +revisions. The Licensor may do this by writing it explicitly or +suffixing the License URI with any additional version numbers each +separated by a comma. + +# Miscellaneous + +Each time You Distribute or Publicly Perform the Work or a Collection, +the Licensor offers to the recipient a license to the Work on the same +terms and conditions as the license granted to You under this License. + +Each time You Distribute or Publicly Perform an Adaptation, Licensor +offers to the recipient a license to the original Work on the same terms +and conditions as the license granted to You under this License. + +If the Work is classified as Software, each time You Distribute or +Publicly Perform an Adaptation, Licensor offers to the recipient a copy +and/or URI of the corresponding Source Code on the same terms and +conditions as the license granted to You under this License. + +If the Work is used as a Network Service, each time You Distribute or +Publicly Perform an Adaptation, or serve data derived from the Software, +the Licensor offers to any recipients of the data a copy and/or URI of +the corresponding Source Code on the same terms and conditions as the +license granted to You under this License. + +If any provision of this License is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this License, and without further action +by the parties to this agreement, such provision shall be reformed to +the minimum extent necessary to make such provision valid and +enforceable. + +No term or provision of this License shall be deemed waived and no +breach consented to unless such waiver or consent shall be in writing +and signed by the party to be charged with such waiver or consent. + +This License constitutes the entire agreement between the parties with +respect to the Work licensed here. There are no understandings, +agreements or representations with respect to the Work not specified +here. Licensor shall not be bound by any additional provisions that may +appear in any communication from You. This License may not be modified +without the mutual written agreement of the Licensor and You. + +The rights granted under, and the subject matter referenced, in this +License were drafted utilizing the terminology of the Berne Convention +for the Protection of Literary and Artistic Works (as amended on +September 28, 1979), the Rome Convention of 1961, the WIPO Copyright +Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and +the Universal Copyright Convention (as revised on July 24, 1971). These +rights and subject matter take effect in the relevant jurisdiction in +which the License terms are sought to be enforced according to the +corresponding provisions of the implementation of those treaty +provisions in the applicable national law. If the standard suite of +rights granted under applicable copyright law includes additional rights +not granted under this License, such additional rights are deemed to be +included in the License; this License is not intended to restrict the +license of any rights under applicable law. diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index e8014dc..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,248 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "android_system_properties" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7ed72e1635e121ca3e79420540282af22da58be50de153d36f81ddc6b83aa9e" -dependencies = [ - "libc", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bumpalo" -version = "3.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "chrono" -version = "0.4.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" -dependencies = [ - "iana-time-zone", - "js-sys", - "num-integer", - "num-traits", - "time", - "wasm-bindgen", - "winapi", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" - -[[package]] -name = "dit-rs" -version = "0.0.0" -dependencies = [ - "chrono", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad2bfd338099682614d3ee3fe0cd72e0b6a41ca6a87f6a74a3bd593c91650501" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "js-sys", - "wasm-bindgen", - "winapi", -] - -[[package]] -name = "js-sys" -version = "0.3.59" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "libc" -version = "0.2.132" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" - -[[package]] -name = "log" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg", -] - -[[package]] -name = "once_cell" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e" - -[[package]] -name = "proc-macro2" -version = "1.0.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "syn" -version = "1.0.99" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "time" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" -dependencies = [ - "libc", - "wasi", - "winapi", -] - -[[package]] -name = "unicode-ident" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf" - -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - -[[package]] -name = "wasm-bindgen" -version = "0.2.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index 050a6b4..60bdfe4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,4 @@ -[package] -name = "dit-rs" -version = "0.0.0" -edition = "2021" -authors = ["Miraty "] +[workspace] +members = ["dit", "stardit", "libdit", "libstardit"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -chrono = "0.4" diff --git a/PKGBUILD b/PKGBUILD index e47ad81..3d06e8a 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -6,15 +6,21 @@ makedepends=('cargo') arch=('i686' 'x86_64' 'armv6h' 'armv7h') prepare() { - cargo fetch --locked --target "$CARCH-unknown-linux-gnu" + cargo fetch --locked --target "$CARCH-unknown-linux-gnu" } build() { - export RUSTUP_TOOLCHAIN=stable - export CARGO_TARGET_DIR=target - cargo build --frozen --release --all-features + export RUSTUP_TOOLCHAIN=stable + export CARGO_TARGET_DIR=target + cargo build --frozen --release --all-features +} + +check() { + export RUSTUP_TOOLCHAIN=stable + cargo test --frozen --all-features } package() { - install -Dm0755 -t "$pkgdir/usr/bin/" "target/release/$pkgname" + install -Dm0755 -t "$pkgdir/usr/bin/" "target/release/dit" + install -Dm0755 -t "$pkgdir/usr/bin/" "target/release/stardit" } diff --git a/README.md b/README.md index e856d16..47171d9 100644 --- a/README.md +++ b/README.md @@ -39,4 +39,4 @@ Feel free to make pull requests or open issues. ## License -See [UNLICENSE](UNLICENSE). +[CNPL-NAv7](CNPL-NAv7.md)+ diff --git a/UNLICENSE b/UNLICENSE deleted file mode 100644 index b3dbff0..0000000 --- a/UNLICENSE +++ /dev/null @@ -1,22 +0,0 @@ -This is free and unencumbered software released into the public domain. - -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. - -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. - -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 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/dit/Cargo.toml b/dit/Cargo.toml new file mode 100644 index 0000000..b4cb4e4 --- /dev/null +++ b/dit/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "dit" +version = "0.0.0" +edition = "2021" +authors = ["Miraty "] + +[dependencies] +libdit = { path = "../libdit" } +libstardit = { path = "../libstardit" } diff --git a/dit/src/main.rs b/dit/src/main.rs new file mode 100644 index 0000000..17aab72 --- /dev/null +++ b/dit/src/main.rs @@ -0,0 +1,30 @@ +pub use std::time::{SystemTime,UNIX_EPOCH}; +use libdit::libdit::Dit; +use std::str::FromStr; +pub use libdit::libdit::unix_to_dit_string; +pub use libstardit::libstardit::unix_to_stardit; + +fn main() { + /* + let code: &str = &r"0.12.34"; + match Dit::from_str(code) { + Ok(dit) => { + println!( + r"Dit: deca: {} decim: {} desec: {}", + dit.deca, dit.decim, dit.desec + ); + } + Err(_) => { + println!("{} is not a valid DIT!", code); + } + } +*/ + let current_timestamp = SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap() + .as_secs_f64(); + + let stardit = unix_to_stardit(current_timestamp); + + println!("{}\n{}, décade {}, {}", unix_to_dit_string(current_timestamp), stardit.year, stardit.weekade, stardit.day_name); +} diff --git a/libdit/Cargo.toml b/libdit/Cargo.toml new file mode 100644 index 0000000..a3ebf77 --- /dev/null +++ b/libdit/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "libdit" +version = "0.0.0" +edition = "2021" +authors = ["Miraty "] + diff --git a/libdit/src/lib.rs b/libdit/src/lib.rs new file mode 100644 index 0000000..202c9f5 --- /dev/null +++ b/libdit/src/lib.rs @@ -0,0 +1,50 @@ +pub mod libdit { + use std::str::FromStr; + + /// Represents a time in a StarDIT day + pub struct Dit { + pub deca: u16, + pub decim: u16, + pub desec: u16 + } + + impl FromStr for Dit { + type Err = std::num::ParseIntError; + + fn from_str(dit: &str) -> Result { + return Ok(Dit { + deca: u16::from_str_radix(&dit[0..1], 10)?, + decim: u16::from_str_radix(&dit[2..4], 10)?, + desec: u16::from_str_radix(&dit[5..7], 10)? + }); + } + } + + /// Returns relative progress in the day, between 0 and 1 corresponding to `unix` + pub fn unix_to_dit(unix: f64) -> f64 { + return (unix - (12.0*3600.0)) % 86400.0 / 86400.0; + } + + /// Returns a struct containing deca, decim and desec corresponding to `unix` + pub fn unix_to_dit_struct(unix: f64) -> Dit { + let dit = unix_to_dit(unix); + return Dit { + deca: (dit * 10.0 % 10.0) as u16, + decim: (dit * 1000.0 % 100.0) as u16, + desec: (dit * 100000.0 % 100.0) as u16 + }; + } + + /// Returns a string containing "deca.decim.desec" corresponding to `unix` + /// + /// # Examples + /// + /// ``` + /// use libdit::libdit::unix_to_dit_string; + /// assert_eq!("9.99.99", unix_to_dit_string(1672574399.9999)); + /// ``` + pub fn unix_to_dit_string(unix: f64) -> String { + let dit = unix_to_dit_struct(unix); + return format!("{}.{}.{}", dit.deca, format!("{:0>2}", dit.decim), format!("{:0>2}", dit.desec)); + } +} diff --git a/libdit/tests/libdit.rs b/libdit/tests/libdit.rs new file mode 100644 index 0000000..fe3eab6 --- /dev/null +++ b/libdit/tests/libdit.rs @@ -0,0 +1,9 @@ +use libdit::libdit::unix_to_dit_string; + +#[test] +fn test_unix_to_dit_string() { + assert_eq!("3.57.13", unix_to_dit_string(938056.836)); + + assert_eq!("9.99.99", unix_to_dit_string(1672574399.9999)); + assert_eq!("0.00.00", unix_to_dit_string(1672574400.0000)); +} diff --git a/libstardit/Cargo.toml b/libstardit/Cargo.toml new file mode 100644 index 0000000..7e293c1 --- /dev/null +++ b/libstardit/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "libstardit" +version = "0.0.0" +edition = "2021" +authors = ["Miraty "] + +[dependencies] +chrono = "0.4" diff --git a/libstardit/src/lib.rs b/libstardit/src/lib.rs new file mode 100644 index 0000000..7390289 --- /dev/null +++ b/libstardit/src/lib.rs @@ -0,0 +1,38 @@ +extern crate chrono; + +pub mod libstardit { + use chrono::{TimeZone, Datelike, LocalResult}; + + pub struct StarDIT { + pub year: u16, + pub weekade: u16, + pub day_name: String, + pub day: u16 + } + + pub fn unix_to_stardit(unix: f64) -> StarDIT { + let date = match chrono::Utc.timestamp_millis_opt(((unix as i64) - 12*3600) * 1000) { + LocalResult::Single(date) => date, + _ => panic!("Incorrect timestamp_millis"), + }; + let day = date.ordinal() as u16; + return StarDIT { + year: (date.year() + 10000) as u16, + weekade: day / 10, + day_name: match day % 10 { + 0 => "zéridi", + 1 => "unidi", + 2 => "duodi", + 3 => "tridi", + 4 => "quartidi", + 5 => "quintidi", + 6 => "sextidi", + 7 => "septidi", + 8 => "octidi", + 9 => "nonidi", + _ => "?", + }.to_string(), + day: day, + }; + } +} diff --git a/libstardit/tests/libstardit.rs b/libstardit/tests/libstardit.rs new file mode 100644 index 0000000..e7b5ba8 --- /dev/null +++ b/libstardit/tests/libstardit.rs @@ -0,0 +1,25 @@ +use libstardit::libstardit::unix_to_stardit; + +#[test] +fn test_unix_to_stardit_year() { + assert_eq!(12022, unix_to_stardit(1672574399.9999).year); + assert_eq!(12023, unix_to_stardit(1672574400.0000).year); +} + +#[test] +fn test_unix_to_stardit_weekade() { + assert_eq!(36, unix_to_stardit(1672574399.9999).weekade); + assert_eq!(0, unix_to_stardit(1672574400.0000).weekade); +} + +#[test] +fn test_unix_to_stardit_day() { + assert_eq!(365, unix_to_stardit(1672574399.9999).day); + assert_eq!(1, unix_to_stardit(1672574400.0000).day); +} + +#[test] +fn test_unix_to_stardit_day_name() { + assert_eq!("quintidi", unix_to_stardit(1672574399.9999).day_name); + assert_eq!("unidi", unix_to_stardit(1672574400.0000).day_name); +} diff --git a/src/main.rs b/src/main.rs deleted file mode 100644 index a8fd348..0000000 --- a/src/main.rs +++ /dev/null @@ -1,49 +0,0 @@ -use std::time::{SystemTime,UNIX_EPOCH}; -use chrono::{Duration,Datelike}; - -fn main() { - - // DIT - - let current_timestamp = SystemTime::now() - .duration_since(UNIX_EPOCH) - .unwrap() - .as_secs_f64(); - - let current_dit = (current_timestamp - 12.0*3600.0) % 86400.0 / 86400.0; - - let deca = (current_dit * 10.0 % 10.0) as u16; - let decim = (current_dit * 1000.0 % 100.0) as u16; - let desec = (current_dit * 100000.0 % 100.0) as u16; - - // StarDIT - - let date_opt = chrono::Utc::now().checked_add_signed(Duration::hours(-12)); - let date = match date_opt { - Some(date) => date, - None => panic!("Time overflow"), - }; - - let year = date.year() + 10000; - let day = date.ordinal(); - - let day_name = match day % 10 { - 0 => "zéridi", - 1 => "unidi", - 2 => "duodi", - 3 => "tridi", - 4 => "quartidi", - 5 => "quintidi", - 6 => "sextidi", - 7 => "septidi", - 8 => "octidi", - 9 => "nonidi", - _ => "?", - }; - - let weekade = day / 10; - - // Display - println!("{}.{}.{}\n{}, décade {}, {}", deca, format!("{:0>2}", decim), format!("{:0>2}", desec), year, weekade, day_name); -} - diff --git a/stardit/Cargo.toml b/stardit/Cargo.toml new file mode 100644 index 0000000..88b1f6b --- /dev/null +++ b/stardit/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "stardit" +version = "0.0.0" +edition = "2021" +authors = ["Miraty "] + +[dependencies] +libstardit = { path = "../libstardit" } diff --git a/stardit/src/main.rs b/stardit/src/main.rs new file mode 100644 index 0000000..8301576 --- /dev/null +++ b/stardit/src/main.rs @@ -0,0 +1,56 @@ +pub use std::time::{SystemTime,UNIX_EPOCH}; +pub use libstardit::libstardit::unix_to_stardit; + +fn main() { + let current_timestamp = SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap() + .as_secs_f64(); + let stardit = unix_to_stardit(current_timestamp); + + let day_stop: u16 = match is_leap_year(stardit.year as i32) { + false => 365, + true => 366, + }; + + print!("déc "); + + for day_number_wkd in 0..10 { + let day_name = unix_to_stardit((day_number_wkd as f64 * 86400.0) + 864000.0).day_name; + + let day_name_abbr = match day_name.char_indices().nth(3) { + None => day_name, + Some((idx, _)) => day_name[..idx].to_string(), + }; + + if day_number_wkd == stardit.day % 10 { + print!("\x1b[1m{}\x1b[0m ", day_name_abbr); + } else { + print!("{} ", day_name_abbr) + } + } + + print!("\n 0 "); + let mut day_i: u16 = 1; + while day_i <= day_stop { + if day_i % 10 == 0 { + print!("\n"); + if day_i / 10 == stardit.day / 10 { + print!("\x1b[1m{}\x1b[0m ", format!("{: >3}", day_i / 10)); + } else { + print!("{} ", format!("{: >3}", day_i / 10)); + } + } + if day_i == stardit.day { + print!("\x1b[7m{}\x1b[0m ", format!("{: >3}", day_i)); + } else { + print!("{} ", format!("{: >3}", day_i)); + } + day_i += 1; + } + print!("\n"); +} + +fn is_leap_year(year: i32) -> bool { + return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0) +}