19

I find this amazing small piece of code in this question:

datediff() {
   d1=$(date -d "$1" +%s)
   d2=$(date -d "$2" +%s)
   echo $(( (d1 - d2) / 86400 )) days
}

Does being on the site make this content open source and if yes what is the license of it ?
In this case this is an answer but I ask myself the same for question.

1
  • It could be an interesting question, what is with the license of the code which is not own work, but included from external sources, for example for illustration/demonstration purposes. Brrr.....
    – peterh
    Mar 29, 2018 at 19:31

1 Answer 1

24

As the footer and various other places indicate, user contributions are licensed CC-BY-SA 3.0. There was an attempt to have code snippets be licensed using the MIT license, but it didn't pan out. A New Code License: The MIT, this time with Attribution Required

6
  • 3
    Nice ! I never read the footer :D
    – Kiwy
    Mar 26, 2018 at 15:38
  • 2
    Also, users are free to grant more permissions explicitly. Some do on a regular basis. Others don't think about it but might should you ask them.
    – spectras
    Mar 28, 2018 at 12:23
  • 1
    In addition there is fair use: If code is in a manual, or instructional book (such as this site), then most jurisdictions will see the use of small snippets as fair-use. For example if your example was called dateDifferenceInDays, then the implementation is possibly the only way to do it in a shell script. Or after leaning how to do an if, then every-time you do an if, it will necessarily be a copy, as there is only one way to do it. This is not an infringement of copy-right. Who owns the copy-right on if (no body). Apr 3, 2018 at 14:15
  • if the code is non-trivial, note that BY-SA 3.0 can be included in BY-SA 4.0 which can be included in GPL 3.0 or later
    – lofidevops
    Apr 8, 2018 at 12:36
  • @d3vid while 3.0 is compatible with 4.0 (and all future versions), I don't think that means you can use 3.0-licensed code as if it were licensed with 4.0
    – muru
    Apr 8, 2018 at 13:19
  • I believe you can include it in an adapted work: opensource.stackexchange.com/a/2213 and opensource.stackexchange.com/a/4005
    – lofidevops
    Apr 8, 2018 at 13:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .