# Class Templates + Timestamp = Weird behavior

**URL:** https://discourse.notenik.app/t/class-templates-timestamp-weird-behavior/213
**Category:** Bug Reports
**Created:** [April 29, 2023, 10:30pm UTC](https://discourse.notenik.app/t/class-templates-timestamp-weird-behavior/213 "2023-04-29T22:30:38Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![ThePrinter](https://discourse.notenik.app/user_avatar/discourse.notenik.app/theprinter/32/429_2.png) [@ThePrinter](https://discourse.notenik.app/u/ThePrinter)
#### Post date: [April 29, 2023, 10:30pm UTC](https://discourse.notenik.app/t/class-templates-timestamp-weird-behavior/213/1 "2023-04-29T22:30:38Z")

</div>

This is an interesting bug and it’s taken a little bit of time to get a firm grasp on what’s happening, but I think I’ve figured it out well enough to easily explain it.

If a Collection has notes that contain Timestamps and Classes, then Notenik will produce duplicate or inaccurate Timestamps, depending on a note’s Class and/or the method that the note is produced by. I’ve made multiple test collection to try and pin down exactly what’s happening, but this bug appears to depend on whether the Note was made via the `New Note` command or `New Note w/ Options` _and_ the Class of the note itself.

It looks like Notenik sort of “groups” notes across a set of duplicate Timestamps. At most, I’ve gotten three individual Timestamps with which duplicates will be made from. How a note is “grouped” depends on how it was made.

For example, the first Timestamp in a Collection, `20230429214739` will be given to all Notes with a `default` Class and all notes (irrespective of their Class) made with the `New Note` command (or `Command-N`). The second Timestamp, `20230429214800` will be given to all notes with the Class `quotation` that are made via the `New Note w/ Options` command (or `Command-Option-N`). A third Timestamp, `20230429214817` can be given to all notes with the Class `summary` that are made via `New Note w/ Options`.

I haven’t tested this bug out with more than three classes, but I imagine that a fourth note would receive a fourth Timestamp if it was made with the `New Note w/ Options` command.

The times provided in these Timestamps will also have inaccurate values in minutes and seconds (I understand that Timestamps are generated in GMT+0 and the hours are consistent with that).

[Here is a sample collection](https://discourse.notenik.app/uploads/short-url/bb4qlRydFSr0PUnyvJj6bUvfxo2.zip) (5.8 KB): I hope that it sort of captures what I’m trying to describe.

If I you feel like I haven’t been clear with certain parts of my description of this bug, please let me know. It’s a strange one. Thank you, Herb!

---

<div class="post-metadata">

### Author: ![ThePrinter](https://discourse.notenik.app/user_avatar/discourse.notenik.app/theprinter/32/429_2.png) [@ThePrinter](https://discourse.notenik.app/u/ThePrinter)
#### Post date: [April 30, 2023, 9:36am UTC](https://discourse.notenik.app/t/class-templates-timestamp-weird-behavior/213/2 "2023-04-30T09:36:59Z")

</div>

**In regard to Timestamps generation** :  
I’m also observing that Notenik is generating some Timestamps that are incompatible with the 24–hour time format, e.g. `20230430240859`. The 24th hour should be denoted with `00` instead of a literal `24`.

---

<div class="post-metadata">

### Author: ![hbowie](https://discourse.notenik.app/user_avatar/discourse.notenik.app/hbowie/32/6_2.png) [@hbowie](https://discourse.notenik.app/u/hbowie)
#### Post date: [April 30, 2023, 4:57pm UTC](https://discourse.notenik.app/t/class-templates-timestamp-weird-behavior/213/3 "2023-04-30T16:57:29Z")

</div>

Thanks for the bug reports! Looking into them now.

You are correct, in that Notenik is reporting hours in the 1 - 24 range, rather than the 0 - 23 range, when generating timestamp values.

Here is the relevant spec for the date and time formatting codes: [unicode spec for date format patterns](http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns).

Notenik is currently using the following string: `yyyyMMddkkmmss`. It is the `kk` part that is causing the behavior in question. You’re suggesting I should instead use the `HH` code.

I think you’re correct in that the 0 - 23 range is more common. What’s more (and probably more important) is that use of the 1 - 24 range would cause a time of 12:30 am to come _after_ a time of 12:30 pm!

I’ll make the change you suggest.

Thanks again!

---

<div class="post-metadata">

### Author: ![ThePrinter](https://discourse.notenik.app/user_avatar/discourse.notenik.app/theprinter/32/429_2.png) [@ThePrinter](https://discourse.notenik.app/u/ThePrinter)
#### Post date: [April 30, 2023, 5:41pm UTC](https://discourse.notenik.app/t/class-templates-timestamp-weird-behavior/213/4 "2023-04-30T17:41:18Z")

</div>

Interesting. I do love a nice visit to a technical standard. Thank you, Herb and I’m glad that I can help.

---

<div class="post-metadata">

### Author: ![hbowie](https://discourse.notenik.app/user_avatar/discourse.notenik.app/hbowie/32/6_2.png) [@hbowie](https://discourse.notenik.app/u/hbowie)
#### Post date: [April 30, 2023, 6:23pm UTC](https://discourse.notenik.app/t/class-templates-timestamp-weird-behavior/213/5 "2023-04-30T18:23:20Z")

</div>

Great detective work! I think I’ve found and fixed the timestamp problem. Will post a beta soon so you can (hopefully) verify.

---

<div class="post-metadata">

### Author: ![ThePrinter](https://discourse.notenik.app/user_avatar/discourse.notenik.app/theprinter/32/429_2.png) [@ThePrinter](https://discourse.notenik.app/u/ThePrinter)
#### Post date: [April 30, 2023, 8:52pm UTC](https://discourse.notenik.app/t/class-templates-timestamp-weird-behavior/213/6 "2023-04-30T20:52:57Z")

</div>

Great news! I look forward to checking it out, thanks.

---

<div class="post-metadata">

### Author: ![hbowie](https://discourse.notenik.app/user_avatar/discourse.notenik.app/hbowie/32/6_2.png) [@hbowie](https://discourse.notenik.app/u/hbowie)
#### Post date: [May 2, 2023, 4:56pm UTC](https://discourse.notenik.app/t/class-templates-timestamp-weird-behavior/213/7 "2023-05-02T16:56:10Z")

</div>

See the [latest beta](https://discourse.notenik.app/t/beta-version-11-9-4-available-for-testing-on-may-2nd-2023/215). I think this should fix the problem you found.
