Date System using negative Numbers

I am writing a sci-fi novel set a million years in the future. I have decided the simplest way is to use positive and negative numbers around a key point in time where my narrative formally begins which is date 0.

However, at present if I use a simple text field for the meta-field and use a negative sign it will not order the negative numbers correctly. Do you have a suggestion as to how I could do this? Or can you create an enhancement to the metafield options that would handle this scenario? This is like a BC/AD type of date system.

Example:

-1,000,000/01/01
-800,000/01/01
-700,000/01/01
-200,000/01/01
0/01/01
14/01/01
120/01/01
300/01/01

Thanks so much! Loving Scrivener 3.

I’m not thinking of anything off of the top of my head, but it wouldn’t surprise me if someone has battled this one before. Basically the problem is that you want the following variables:

  • Million+ year date reckoning.
  • Positive and negative nomenclature.
  • A system that works in a typical alphanumeric sorting algorithm.

Maybe see what geologists do? :wink:

EDIT: I was not thinking this through, or I would have noted that alphabetic sorting treats -1 as “less than” -9, since it just storts minus signs (both the same), and then sorts 1 vs 9. Please disregard this post.


Since scrivener doesn’t have a numeric metadata field type (date doesn’t count), you have to rely on sorting numbers like text, which works just like alphabetic sorting does. In other words…

  1. Sort everything by 1st character, then by 2nd character within groups that have the same 1st, then by 3rd character within groups with the same 1st & 2nd character, etc…
  2. Sort shorter strings (words) before longer strings (words) if the longer string starts with the shorter string. (Ex: “too” comes before “took”, alphabetically)
  3. Sorting numbers this way means ALL numbers must have the same number of digits (and must include the same punctuation in the same positions). Padding to the left with zeroes is how you do that. You’re already doing something similar with the month and day numbers, adding leading zeroes to the 1s.
  4. Sorting “dates” like this also requires that you start with the largest unit of time as the first part of each date, and get smaller as you move right, which you’re doing. The American standard of Month-Day-Year wouldn’t sort that way (which is why I’m glad Scrivener backups get a date formatted to sort properly, instead of relying on the system default).
  5. You can get more precise to the right, adding a time stamp (24 hour time, or equivalent for whatever planet you’re telling time on). Adding extra sortable time units to the right assumes midnight on those dates without any time specified.
  6. Lucky for you, I believe “-” sorts before “+”, so you can continue using those symbols.

In your example, the numbers/dates have to all be changed to this to sort properly:
-1,000,000/01/01
-0,800,000/01/01
-0,700,000/01/01
-0,200,000/01/01
+0,000,000/01/01
+0,000,014/01/01
+0,000,120/01/01
+0.000,300/01/01

This also makes things line up properly, so you have that going for you.

Sadly, I just tried this and the numbers actually sorted:

-0,200,000/01/01
-0,700,000/01/01
-0,800,000/01/01
-1,000,000/01/01
+0,000,000/01/01
+0,000,014/01/01
+0,000,120/01/01
+0.000,300/01/01

Dammit! I forgot about negative magnitudes… alpha-sorting ignores that -1 million is less than -1 hundred, even with leading zeroes making everything line up. Sorry. For positive numbers only, alphabetic sorting works on numbers & numerical dates and times that are left-padded with zeroes (and which use 24hr time); I have to deal with file names with dates being the most accurate way to sort data all the time, but my dates never go negative.

Thanks for testing my hypothesis, SilverDragon.

Following rdale’s suggestion, does it work in two stages: sort the negative numbers descending; the positive numbers ascending?

No, I was wrong in how alpha sorting treats negative numbers. Please disregard my post.

Okay, but in my test, the numbers come out as you list them…

How odd. I don’t have my Mac with me today, so I can’t test this… Scrivener sorts this information as a custom metadata text field the same as my example? Or are you using some other metadata type? Because the negative years should sort in the opposite order, as SilverDragon claims they do.

Ah, I’m just dropping the numbers into the body of a text file and then using the sort tools. My error. Apologies.

My meta sort doesn’t look like Silverdragon’s. I get…

Bridey: Did you use a Text metadata field, or a Date metadata field? I assume it’s not a Checkbox metadata field, and I don’t recall any other types… That may be the key to how people are getting different results.

Hi.

I called the field ‘date’, but used a ‘text’ type.

Types are: text, checkbox, list, and date

Now that I’m less distracted, I just noticed that your sorted dates are in descending order if you ignore the postive/negative symbols. The order it should be (to reflect how our own BC/AD dates work) would be as I originally listed them. Your sort order has the largest positive date (year 300) as the next value after -0,200,000/01/01. The first positive date after the year -200,000 should be +0,000,000/01/01.

Absolutely. I posted just to show the difference to what Silverdragon saw in her test.

Sort again and the positive dates go into the right order, but the negative dates are inverted. If it were possible to treat the negatives and positives as two discrete groups, each could be sorted correctly. As it is, one group is right at any time (I think), which might well help the OP with their needs. So, I believe your idea pretty much works…unless I have misunderstood all along.

Removing the plus signs impacts on the sort, but not in a meaningful way. As such, the OP doesn’t need to use the plus signs.

Not at a Mac to be able to test this, but is it possible to use a custom date field that includes the era / extended year?

unicode.org/reports/tr35/tr35-da … terns_Eras

I tried to make that work yesterday, Bridey, using the flag G

G yyyy/MM/dd

shows the date as AD 2018/01/08 as you’d expect, but it doesn’t seem to accept any change of the era to BC or BCE.

I also tried using the flag u (which seems to be exactly what is wanted – it uses a negative number for BCE, but again, while it displays properly, I couldn’t get it to accept input properly.

u/MM/dd

… looks like it should work but it doesn’t.

This is all above my pay grade, I’m afraid, so I gave up. Sorry…

Thanks for that. Will try when back at a Mac. Just a puzzle for me, though it would also be useful for the OP if it did work.

I tried those special date formatting strings as well. Unfortunately the input mechanism is necessarily simpler than the full breadth of the output filters available. So that’s one problem—you can’t type in –342,832/08/29 and get a meaningful result. And only the most passionate and dedicated masochist would try to use the calendar widget to insert a date like that (I even had issues getting BCE dates. I got the calendar down to January 1, 1 CE, but going backward resulted in 2 CE; it may not even be possible).

Basically the inputs all have to be specifically programmed into the software. There must be precise instructions provided to turn an arrangement of numbers, punctuation marks, spaces and so forth into a date object. We went through Wikipedia and added as many different common date formats as we could from around the world—but obviously we didn’t anticipate million year negative values! 8)

So yeah, I don’t think a date metadata field is the right answer for exotic calendars like this.

Thanks for the answer and explanation, Ioa.

I think rdale’s idea works well enough: each set of dates (positive and negative) can be sorted to give a timeline, even if there is a slight bump in the ascending–descending road.

The OP could also create a suitable key to delineate the dates and then sort by that key. Not perfect, but it would work.