# Node-red-contrib-simpletime enhancement

**URL:** <https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069>\
**Category:** Developing Nodes\
**Created:** [23 June 2020 12:38 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069 "2020-06-23T12:38:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [23 June 2020 12:38 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/1 "2020-06-23T12:38:30Z")

</div>

Carrying on from this thread

> [@Easy way of adding only mytimes to a msg](https://discourse.nodered.org/t/easy-way-of-adding-only-mytimes-to-a-msg/28683):
>
> The node-red-contrib-simpletime does what its says on the packet and returns the current (DST corrected) time Instead of writing my own boiler plate code to add hh:mm:ss to status/logging messages I'd thought I'd just use this node in the flow and just add in mytimes but I'm struggling to come up with a simple way of doing it without adding in all the others as well Any clever/simple ideas?

@Paul-Reed

It occurs to me anyway, that being able to just use simpletime for single/partial myXXXXX payloads by having a set of tick boxes would be an enhancement for the node (default being all of course)

What do you think?

I'd do the work to acheive it and send your a PR if you approve the concept 🙂

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [23 June 2020 13:15 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/2 "2020-06-23T13:15:37Z")

</div>

> [@cymplecy](#):
>
> having a set of tick boxes would be an enhancement for the node

Sounds good to me 👍

I've added a feature branch - `tickboxes` to the repo, so we can see what it looks like.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [27 June 2020 07:15 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/3 "2020-06-27T07:15:07Z")

</div>

I think I've tested it out enough on my systems (3 of them inc new beta) and I'm happy that it works so PR on its way

I incremented version to 2.9.2 - having found out that saying 2.9.1\_cymplecy doesn't work 🙂

If you publish it as is, it'd be nice if you could increment it again so I can tell difference on my systems 🙂

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [27 June 2020 07:18 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/4 "2020-06-27T07:18:08Z")

</div>

PS Other edits just to replace tab spacing with 4 space spacing on a couple of lines

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [27 June 2020 15:36 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/5 "2020-06-27T15:36:44Z")

</div>

Nice work Simon!  
~~I've merged it into the `tickboxes` feature branch, which can be loaded by;~~

~~ 

```auto
cd .node-red
npm install Paul-Reed/node-red-contrib-simpletime#tickboxes

```

 ~~

~~It will then overwrite your existing version.~~  
EDIT - now merged into master branch.

Don't know if it's even possible... but it would be nice to have `select none` & `select all` button/link/whatever in the node properties???

![simples](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/a/5a8c57da97a56e08edb5f260e9dd1f54070ed830.jpeg)

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [27 June 2020 16:29 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/6 "2020-06-27T16:29:30Z")

</div>

> [@Paul-Reed](#):
>
> Don't know if it's even possible... but it would be nice to have `select none` & `select all` button/link/whatever in the node properties???

Drat - I was hoping to slip that past you 🙂

Can I suggest that once your happy with the modification and have merged it into the main branch - you then create another new branch (I've already deleted my fork) and I'll fork that and then work out how add those options?

On another note - I could do with having a yymmdd option for writing stuff to my logging system(and therefore maybe there should be a yyyymmdd and a yyyy-mm-dd ones as well?)

And I'm contemplating asking for a hh:mm:ss.zzz one as well but only for completeness - I'm not sure I can fully justify it but I just think that maybe it should be there?

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [27 June 2020 16:46 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/7 "2020-06-27T16:46:43Z")

</div>

> [@cymplecy](#):
>
> and have merged it into the main branch - you then create another new branch

Merged into Master branch and a new `tickboxes` branch added.

> [@cymplecy](#):
>
> On another note - I could do with having a yymmdd option for writing stuff to my logging system(and therefore maybe there should be a yyyymmdd and a yyyy-mm-dd ones as well?)

I started off with the intentions of just providing the basic elements, with a view to any combination of the elements then being constructed using a template node, but a few combinations crept in....  
However, I quickly realised that there are countless combinations of those elements, and potentially the node could become swamped with options as different users request different elements in different orders, some with hyphens, some with slashes, etd, so would prefer if possible to avoid, unless it's something which is a well used standard date/time format, or something that couldn't be easily constructed.  
Does that make sense?

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [27 June 2020 18:38 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/8 "2020-06-27T18:38:20Z")

</div>

> [@Paul-Reed](#):
>
> Does that make sense?

Fully  
Can I make my case 🙂

1. I'll accept just getting one variation added if I can 🙂

2. So, you have mytime hh:mm and mytimes hh:mm:ss but no equivalent yy-mm-dd type date - to get the date - you either have to concat 3 properties or (even worse) substring myrawdate and get the "wrong" date as myrawdate is not local DST corrected

So I think its a fundamental missing property

I'd vote for yymmdd personally (as its shortest I can use in logging) but happy to accept yy-mm-dd or yyyymmdd or yyyy-mm-dd if you accept the basic proposal

I rest my case 🙂

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [27 June 2020 20:11 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/9 "2020-06-27T20:11:50Z")

</div>

[ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) recommends a locale neutral date format of `yyyy-mm-dd` so yes, let's go with that. 👍

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [27 June 2020 20:47 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/10 "2020-06-27T20:47:34Z")

</div>

> [@cymplecy](#):
>
> I incremented version to 2.9.2 - having found out that saying 2.9.1\_cymplecy doesn't work 🙂
> 
> If you publish it as is, it'd be nice if you could increment it again so I can tell difference on my systems

Cough............................

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [27 June 2020 21:02 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/11 "2020-06-27T21:02:28Z")

</div>

You should be able to call it what you like. But you will have to use the exact name to install it.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [27 June 2020 21:14 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/12 "2020-06-27T21:14:09Z")

</div>

I'm a bit (more ) confused now - when I tried changing node version number in the branch I was using from 2.9.1 to 2.9.1\_cymplecy , I then couldn't install it using npm install

Got a very wierd error that didn't make a lot sense (end of stream??? something wierd like that anyway)

When I changed it to 2.9.2 - I could then do an npm install

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [27 June 2020 21:16 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/13 "2020-06-27T21:16:10Z")

</div>

> [@cymplecy](#):
>
> If you publish it as is, it'd be nice if you could increment it again

I haven't published it to npm yet, only committed it to the git repo.  
You don't need to increment the package, as I will sort out the semantic version prior to publishing it.  
The version number shouldn't affect your local installation, as I assume you are installing it from git, ie from my repo it would be as below, but you'll be using your repo.

```auto
cd .node-red
npm install Paul-Reed/node-red-contrib-simpletime#tickboxes

```

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [27 June 2020 21:19 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/14 "2020-06-27T21:19:00Z")

</div>

I've lost the plot now  
I'll wait to see what happens when the github/npm publishing dust has settled and then come back if I've got an issue 🙂

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [27 June 2020 21:42 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/15 "2020-06-27T21:42:22Z")

</div>

> [@cymplecy](#):
>
> I've lost the plot now

If you make a fork of the simpletime repo, you can then install it over the top of your existing simpletime node that you have already installed in your node-RED installation,

```auto
cd .node-red
npm install cymplecy/node-red-contrib-simpletime

```

It doesn't matter about the version, it will update it regardless.Then you make whatever changes you need locally.  
If you later decide to create a PR, it doesn't matter if it's to the master or feature branch, as I can switch branches here.

When all the changes are in master, then I'll sort out the versioning and publish it to npm.

Hope that make sense.

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [28 June 2020 00:10 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/16 "2020-06-28T00:10:41Z")

</div>

@cymplecy have you found the changes backwards compatible.  
I've just updated my 2nd system with the latest, and it broke my flows.

Opening the properties of my existing simpletime nodes, all of the options were unticked,

![problem](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/1/110d434a2914f7ab6ba1316670873718a19d5e61.jpeg)

Adding a new simpletime node, they are all selected, however existing nodes are deselected?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [28 June 2020 06:38 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/17 "2020-06-28T06:38:48Z")

</div>

In the oneditprepare you will need to check if each of the new properties is undefined and if so set it to its default.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [28 June 2020 07:55 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/18 "2020-06-28T07:55:05Z")

</div>

On it - re-forking  
..................................

I thought I might need to do something but when I did my final testing I couldn't get them to not be filled in

Trying to make sure I can replicate the issue before I commit any more code

I went back to see what was needed when I was contributing to neopixel node so hopefully this is the syntax I'll need for each myXXXX

```auto
        oneditprepare: function() {
            if (this.mydate === undefined) {
                this.mydate = true;
                $("#node-input-mydate").prop('checked', true);
            }
        }

```

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [28 June 2020 09:26 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/19 "2020-06-28T09:26:04Z")

</div>

> [@cymplecy](#):
>
> so hopefully this is the syntax I'll need for each

So if that ensures backwards compatibility when upgrading, just wondering if the default state for the checkboxes -

```auto
mydate: {value:true},

```

should be **all** ticked or **all** unticked - is it easier to tick the ones that you want, or remove the ticks that you don't want.

What do you think?

EDIT - Having thought about this, I agree with Si, must be 'all ticked'.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [28 June 2020 09:36 UTC](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069/20 "2020-06-28T09:36:23Z")

</div>

for compatibility - I think they should all be ticked so that same result as previous version

That's what I was aiming for

My testing technique obviously failed me so just developing a repeatable setup at moment that fails like what happened to you and then works when I've fixed it 🙂

[Next page](https://discourse.nodered.org/t/node-red-contrib-simpletime-enhancement/29069.md?page=2)
