Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed years on copyright #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

phoebe-leong
Copy link

the copyright will still be valid, and you won't need to keep on updating the year

@jsstrn
Copy link

jsstrn commented Oct 11, 2021

If we use a little bit of JavaScript, we can make the year dynamic.

const date = new Date()
const year = date.getUTCFullYear() // this gives you the current year
const text = `Copyright © 2004 - ${year}`

@phoebe-leong
Copy link
Author

Oh that'd be cool

@phoebe-leong
Copy link
Author

Couldn't it be simplified to

const date = new Date()
const text = `Copyright © 2004 - ${date.getUTCFullYear()}`

I don't know much Javascript, so please correct me if I'm wrong

@jsstrn
Copy link

jsstrn commented Oct 12, 2021

That would depend on what we mean by "simplified."

For instance, we could write our solution like this

const text = `Copyright © 2004 - ${(new Date()).getUTCFullYear()}`

This fits into one line, but is it simplified? 🤷🏽

Perhaps a better way to think of writing code is its ease of readability for humans. Consider the next example,

const date = new Date()
const currentYear = date.getUTCFullYear()

const text = `Copyright © 2004 - ${currentYear}`

While there is a lot more code to read, we might say that it's actually easier to read. This is a matter of style, since both code examples work perfectly.

Though this is a trivial example, you can imagine a complex codebase might contain thousands of lines of code. In such a scenario, it makes a big difference when code is written in a clear and concise manner.

Hope that helps!

@phoebe-leong
Copy link
Author

Hmm. You seem like a smart person, I think I'll add your suggestion

@stanabshub
Copy link

Thanks 👍 for polling

Copy link

@acun87 acun87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be best

Copy link

@Lukas61911 Lukas61911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Copy link

@avindra avindra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants