How to split (parse) date value YYMMDD to individual values for YY, MM, and DD?

164 views
Skip to first unread message

Gordan Nia

unread,
Oct 31, 2017, 10:14:04 AM10/31/17
to TiddlyWiki
How is it possible to split (parse) the YYMMDD date value (eg. from field) into three different values (or fields) that will contain YY, MM, DD in particular?

Thanks!

Gordan

PMario

unread,
Oct 31, 2017, 11:16:49 AM10/31/17
to TiddlyWiki
On Tuesday, October 31, 2017 at 3:14:04 PM UTC+1, Gordan Nia wrote:
How is it possible to split (parse) the YYMMDD date value (eg. from field) into three different values (or fields) that will contain YY, MM, DD in particular?

Why don't you create the stuff in a way that you need?

Can you describe, what you want to achieve? So we may be able to give some hints, to create the whole stuff needed at creation time.

-m

Mark S.

unread,
Oct 31, 2017, 11:24:50 AM10/31/17
to TiddlyWiki
It might help to know what you wanted to accomplish.

There aren't really good tools for splitting things yet. What I would do is call the now macro 3 times, once for each format.

Good luck,
Mar

Gordan Nia

unread,
Oct 31, 2017, 12:21:41 PM10/31/17
to tiddl...@googlegroups.com
I'm using Date Picker plugin (https://kixam.github.io/TW5-datePicker/ ) to get a date in field (format YYMMDD), but for further processing I need to separate the days, months and years eg. into special fields.
So, when a date is picked, the date should be separately represented in 3 fields, not in one.

Thnx!

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/a_2UB0hRpIk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+unsubscribe@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/f39090c4-7bad-4b85-a3ae-5eaa31e62d0b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

 GordaN

PMario

unread,
Oct 31, 2017, 12:42:04 PM10/31/17
to TiddlyWiki
On Tuesday, October 31, 2017 at 5:21:41 PM UTC+1, Gordan Nia wrote:
I'm using Date Picker plugin (https://kixam.github.io/TW5-datePicker/ ) to get a date in field (format YYMMDD), but for further processing I need to separate the days, months and years eg. into special fields.
So, when a date is picked, the date should be separately represented in 3 fields, not in one.

OK ... I see.

As mark pointed out, there is a problem at the moment. ... May be, if this PR would be merged, it would make things easier. ...

So everyone interested should hit the "+1" button there.

-mario



Mark S.

unread,
Oct 31, 2017, 1:20:56 PM10/31/17
to TiddlyWiki
I'm not familiar with the output -- is it in a variable?

I can imagine a solution, which will probably produce some groans, of a cascading <$list> structure. Since you probably have a limited year range, in the outer list you remove all possible years with removeprefix operator. Keep that in a variable "md". Then operate on md to remove all possible months to obtain the day. Use the day then to remove day from md and get the month. Finally remove month and day from the year. Voila! Except I'm not sure it works because some of these operators will only work on actual tiddlers. But it's worth a try.

You could borrow the code from the PR Mario mentions, and help beta test it ;-)


Good luck,
Mark


On Tuesday, October 31, 2017 at 9:21:41 AM UTC-7, Gordan Nia wrote:
I'm using Date Picker plugin (https://kixam.github.io/TW5-datePicker/ ) to get a date in field (format YYMMDD), but for further processing I need to separate the days, months and years eg. into special fields.
So, when a date is picked, the date should be separately represented in 3 fields, not in one.

Thnx!
On Tue, Oct 31, 2017 at 4:16 PM, PMario <pmar...@gmail.com> wrote:
On Tuesday, October 31, 2017 at 3:14:04 PM UTC+1, Gordan Nia wrote:
How is it possible to split (parse) the YYMMDD date value (eg. from field) into three different values (or fields) that will contain YY, MM, DD in particular?

Why don't you create the stuff in a way that you need?

Can you describe, what you want to achieve? So we may be able to give some hints, to create the whole stuff needed at creation time.

-m

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/a_2UB0hRpIk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.

To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.



--

 GordaN

Thomas Elmiger

unread,
Oct 31, 2017, 6:19:40 PM10/31/17
to TiddlyWiki
Hi Gordan,

I made a set of macros some time ago, as I use the same plugin. I have fields with standard TW dates though: YYYYMMDD...

https://tid.li/tw5/hacks.html#%24%3A%2Fplugins%2Ftelmiger%2Flib%2Fdates-then

Maybe you can adapt these? If you are not familiar with macros, please ask again (answers might take some time).

All the best!
Thomas

TonyM

unread,
Oct 31, 2017, 7:10:59 PM10/31/17
to TiddlyWiki
Gordon,

Why parse when you have the tools for dates already available, Am I missing something or are you?. Save the date in a field (you have already done that) then extract the part of the date you want using;eg;

<$view field="created" format="date" template="DDD DDth MMM YYYY"/>

DD: <$view field="created" format="date" template="0DD"/>

MM: <$view field="created" format="date" template="0MM"/>

YY: <$view field="created" format="date" template="YY"/>


Regards
Tony

Gordan Nia

unread,
Nov 2, 2017, 7:50:36 AM11/2/17
to tiddl...@googlegroups.com

Thanks Tony,
but how to put the results of those "views" in different fields or variables?

Regards,
Gordan

Mark S.

unread,
Nov 2, 2017, 10:30:44 AM11/2/17
to TiddlyWiki
First, you would have to tell pik-a-day to store in the standard TW date format (not YYMMDD) Then to put those views into different fields you would need a button to set the fields. Usually when I mention that there needs to be a second step people lose interest.

Here's the starter:

<$wikify name=month text='<$view field="created" format="date" template="0MM"/>'>
<$button>Set Fields
<$action-setfield $field=month month=<
<month>>/>
</$button>
</$wikify>

Nest more $wikify for dd yy and add more action-setfield widgets for other fields.

Good luck!
Mark

Gordan Nia

unread,
Nov 2, 2017, 11:47:02 AM11/2/17
to TiddlyWiki
Thanks Mark,

that's it!

Regards, Gordan
Reply all
Reply to author
Forward
0 new messages