[tw5] Re: Day Number

2020-08-28 Thread Ed Heil
Hey, thanks all.  

That macro is outstanding.  I'd definitely rather exploit existing filter 
techniques than add in a plugin!

I had run across the term "ordinal date" in wikipedia for this thing, and 
"day of year" would also be an intuitively clear way to refer to it.  I'll 
pick one of those to use for my field. :)

On Thursday, August 27, 2020 at 7:52:50 PM UTC-4 Eric Shulman wrote:

> On Thursday, August 27, 2020 at 4:08:23 PM UTC-7, TW Tones wrote:
>>
>> For clarity we would call this the "day of year number" DOY
>>
>
> Based on my recent work with time and date (
> http://TiddlyTools.com/timer.html), I have learned quite a bit about date 
> nomenclature.
>
> In fact, there is a well-defined international standard, ISO-8601 (
> https://en.wikipedia.org/wiki/ISO_8601 
> ), that defines how 
> dates are represented and referenced
>
> Using that international standard, the "day of year number" is called the 
> *"ordinal 
> date"* (https://en.wikipedia.org/wiki/ISO_8601#Ordinal_dates).
>
> Similarly, the standard defines the "week of year" number, which is just 
> referred to as the *"week number"* (
> https://en.wikipedia.org/wiki/ISO_week_date).
>
> There is also a standard for "*weekday number*" which is *"a digit d from 
> 1 through 7, beginning with Monday and ending with Sunday"*
>
> Note that the TWCore date formatting (https://tiddlywiki.com/#DateFormat) 
> that 
> is used by the <> macro already supports "week number" using "WW" and 
> "0WW" formatting codes.  It also supports both 4-digit and 2-digit "year 
> number with respect to week number, using "w" and "wYY" formatting 
> codes respectively.
>
> -e
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/d16bcfc3-bb3f-4645-af2b-9287815301c1n%40googlegroups.com.


[tw5] Re: Day Number

2020-08-27 Thread Eric Shulman
On Thursday, August 27, 2020 at 4:08:23 PM UTC-7, TW Tones wrote:
>
> For clarity we would call this the "day of year number" DOY
>

Based on my recent work with time and date 
(http://TiddlyTools.com/timer.html), I have learned quite a bit about date 
nomenclature.

In fact, there is a well-defined international standard, ISO-8601 (
https://en.wikipedia.org/wiki/ISO_8601 
), that defines how 
dates are represented and referenced

Using that international standard, the "day of year number" is called the 
*"ordinal 
date"* (https://en.wikipedia.org/wiki/ISO_8601#Ordinal_dates).

Similarly, the standard defines the "week of year" number, which is just 
referred to as the *"week number"* (
https://en.wikipedia.org/wiki/ISO_week_date).

There is also a standard for "*weekday number*" which is *"a digit d from 1 
through 7, beginning with Monday and ending with Sunday"*

Note that the TWCore date formatting (https://tiddlywiki.com/#DateFormat) that 
is used by the <> macro already supports "week number" using "WW" and 
"0WW" formatting codes.  It also supports both 4-digit and 2-digit "year 
number with respect to week number, using "w" and "wYY" formatting 
codes respectively.

-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/26eb3c0d-82d9-4b6e-8019-a3cf8238ea9ao%40googlegroups.com.


[tw5] Re: Day Number

2020-08-27 Thread TW Tones
Ed et al.

For clarity we would call this the "day of year number" DOY

as opposed to Day of Month DOM, or Week of Year WOY
but you can also have end of day EOD Beginning of day BOD, 

>From this follows many things BOW, EOM, EOY BOQ/EOQ

Regards
Tony

On Friday, 28 August 2020 05:04:00 UTC+10, Ed Heil wrote:
>
>
> Hi,
>
> I'm interested in populating a field on a tiddler with the "day number" 
> (Jan 1 = 1, Dec 31 = 365 or 366).  There doesn't seem to be an option in 
> the now macro which will give me that number, unless I'm missing 
> something.  
>
> I was thinking this might be a good reason to create my first javascript 
> macro, but poking around the documentation, it's not entirely clear to me 
> how it's possible to create a little one-off javascript macro in a tiddler 
> to use in your wiki, the way you can create a little one-off wikitext 
> macro. 
>
> I was looking at this:
>
> https://tiddlywiki.com/dev/index.html#JavaScript%20Macros
>
> but it talks about developing javascript macros as "modules."  I'm not 
> sure how to add a new module in my wiki... I see there are existing 
> javascript macro modules which are just tiddlers in $:/core/modules/macros  
> ... they look just like some javascript in a tiddler...  could I make 
> something like that?  If so, how?
>
> I know Javascript, I just am missing some very simple first steps as to 
> how to get started on this project.
>
> Of course, if there's some way to get a day number out of the now macro, I 
> wouldn't have to worry about it. :)
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/a675887b-0c6a-459a-a4f0-ca489ff93d87o%40googlegroups.com.


[tw5] Re: Day Number

2020-08-27 Thread Eric Shulman
On Thursday, August 27, 2020 at 12:04:00 PM UTC-7, Ed Heil wrote:
>
> I'm interested in populating a field on a tiddler with the "day number" 
> (Jan 1 = 1, Dec 31 = 365 or 366).  There doesn't seem to be an option in 
> the now macro which will give me that number, unless I'm missing 
> something.  
> Of course, if there's some way to get a day number out of the now macro, I 
> wouldn't have to worry about it. :)
>

Here's a macro that calculates the day number (1 through 365/366) and a 
$button that stores the result in a tiddler field:

\define getDay()
\whitespace trim
<$vars =<> mm=<> dd=<>>
<$set name="dpm" filter="[divide[4]split[.]count[]match[1]]"
 value="31 29 31 30 31 30 31 31 30 31 30 31" emptyValue="31 28 31 30 31 
30 31 31 30 31 30 31">
{{{ [enlist:rawfirstbutlast[]sum[]add] }}}
\end

<$button> set days
<$wikify name="days" text=<>>
<$action-setfield days=<> />



The getDay() macro does this:
* \whitespace trim removes all whitespace from the macro output
* $vars gets the current year (), month (MM) and date (DD)
* $set name="dpm" (days per month) determines if the year is a leap year 
(i.e., evenly divisible by 4) and then defines a list of days per month
* the inline filter enlists the days per month (using :raw to include 
duplicate values)
* then it trims the list to only include the months up to, but not 
including, the current month
* and then sums those numbers and adds the date for the current month

The $button does this:
* $wikify takes the getDay() macro and converts it's output to plain text
* $action-setfield saves the plain text value to the "days" field of the 
current tiddler

enjoy,
-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/37fb371d-4468-45c1-8b9b-6bff1cc4e456o%40googlegroups.com.