ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* date calculated with currentdate plus n days
@ 2018-08-13 15:19 Jan U. Hasecke
  2018-08-13 15:57 ` Pablo Rodriguez
  0 siblings, 1 reply; 9+ messages in thread
From: Jan U. Hasecke @ 2018-08-13 15:19 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi all,

I want to insert a due date for payments in my invoice and I would like
to calculate it from \currentdate. Something like

define \duedate = \currentdate plus 10 days

Is this possible?

juh
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: date calculated with currentdate plus n days
  2018-08-13 15:19 date calculated with currentdate plus n days Jan U. Hasecke
@ 2018-08-13 15:57 ` Pablo Rodriguez
  2018-08-13 17:37   ` Jan U. Hasecke
  0 siblings, 1 reply; 9+ messages in thread
From: Pablo Rodriguez @ 2018-08-13 15:57 UTC (permalink / raw)
  To: ntg-context

On 08/13/2018 05:19 PM, Jan U. Hasecke wrote:
> Hi all,
> 
> I want to insert a due date for payments in my invoice and I would like
> to calculate it from \currentdate. Something like
> 
> define \duedate = \currentdate plus 10 days
> 
> Is this possible?

Hi Jan-Ulrich,

if you don’t mind using Lua, here you have it:

    \starttext
    \def\duedate{\cldcontext{os.date('\letterpercent d/\letterpercent
        m/\letterpercent Y', os.time()+ 10 * 24 * 3600)}}

    \duedate
    \stoptext

Just in case it helps,

Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: date calculated with currentdate plus n days
  2018-08-13 15:57 ` Pablo Rodriguez
@ 2018-08-13 17:37   ` Jan U. Hasecke
  2018-08-13 23:46     ` Henri Menke
  0 siblings, 1 reply; 9+ messages in thread
From: Jan U. Hasecke @ 2018-08-13 17:37 UTC (permalink / raw)
  To: ntg-context

On 13.08.2018 17:57, Pablo Rodriguez wrote:

> if you don’t mind using Lua, here you have it:
> 
>     \starttext
>     \def\duedate{\cldcontext{os.date('\letterpercent d/\letterpercent
>         m/\letterpercent Y', os.time()+ 10 * 24 * 3600)}}
> 
>     \duedate
>     \stoptext
> 
> Just in case it helps,

Thanks!

I thought it should be possible with lua, but I found no entry point to
use lua in context by defining new commands.

juh



___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: date calculated with currentdate plus n days
  2018-08-13 17:37   ` Jan U. Hasecke
@ 2018-08-13 23:46     ` Henri Menke
  2018-08-14  5:29       ` Pablo Rodriguez
  0 siblings, 1 reply; 9+ messages in thread
From: Henri Menke @ 2018-08-13 23:46 UTC (permalink / raw)
  To: ntg-context

On top of that I recommend to use context.date to get the correct 
formatting according to the current language options:

\starttext

\def\duedate{\ctxlua{
   local t = os.date('*t', os.time()+ 10 * 24 * 3600)
   context.date{ d = t.day, m = t.month, y = t.year }
}}

\duedate

\stoptext

On 14/08/18 05:37, Jan U. Hasecke wrote:
> On 13.08.2018 17:57, Pablo Rodriguez wrote:
> 
>> if you don’t mind using Lua, here you have it:
>>
>>      \starttext
>>      \def\duedate{\cldcontext{os.date('\letterpercent d/\letterpercent
>>          m/\letterpercent Y', os.time()+ 10 * 24 * 3600)}}
>>
>>      \duedate
>>      \stoptext
>>
>> Just in case it helps,
> 
> Thanks!
> 
> I thought it should be possible with lua, but I found no entry point to
> use lua in context by defining new commands.
> 
> juh
> 
> 
> 
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
> 
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: date calculated with currentdate plus n days
  2018-08-13 23:46     ` Henri Menke
@ 2018-08-14  5:29       ` Pablo Rodriguez
  2018-08-14  7:24         ` Henri Menke
  0 siblings, 1 reply; 9+ messages in thread
From: Pablo Rodriguez @ 2018-08-14  5:29 UTC (permalink / raw)
  To: ntg-context

On 08/14/2018 01:46 AM, Henri Menke wrote:
> On top of that I recommend to use context.date to get the correct 
> formatting according to the current language options:
> 
> \def\duedate{\ctxlua{
>    local t = os.date('*t', os.time()+ 10 * 24 * 3600)
>    context.date{ d = t.day, m = t.month, y = t.year }
> }}

Many thanks for your reply, Henri.

Where are those context.* Lua commands documented?

I want to generate an xtable using Lua code, but I don’t know where to read.

Many thanks for your help,

Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: date calculated with currentdate plus n days
  2018-08-14  5:29       ` Pablo Rodriguez
@ 2018-08-14  7:24         ` Henri Menke
  2018-08-14 14:58           ` Pablo Rodriguez
  0 siblings, 1 reply; 9+ messages in thread
From: Henri Menke @ 2018-08-14  7:24 UTC (permalink / raw)
  To: ntg-context



On 14/08/18 17:29, Pablo Rodriguez wrote:
> On 08/14/2018 01:46 AM, Henri Menke wrote:
>> On top of that I recommend to use context.date to get the correct
>> formatting according to the current language options:
>>
>> \def\duedate{\ctxlua{
>>     local t = os.date('*t', os.time()+ 10 * 24 * 3600)
>>     context.date{ d = t.day, m = t.month, y = t.year }
>> }}
> 
> Many thanks for your reply, Henri.
> 
> Where are those context.* Lua commands documented?
> 
> I want to generate an xtable using Lua code, but I don’t know where to read.

They aren't documented because they are just the context commands.  You 
can read more about how it works in 
http://www.pragma-ade.nl/general/manuals/cld-mkiv.pdf

Here a little sample with an xtable:

\starttext

\startluacode
local function duedate()
     local t = os.date('*t', os.time()+ 10 * 24 * 3600)
     context.date{ d = t.day, m = t.month, y = t.year }
end

context.startxtable{frame = "off"}
    context.NC() context("Note") context.NC() context("Date") context.NR()
    context.NC() context("Hand in before") context.NC() duedate() 
context.NR()
context.stopxtable()
\stopluacode

\stoptext

> 
> Many thanks for your help,
> 
> Pablo
> 
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: date calculated with currentdate plus n days
  2018-08-14  7:24         ` Henri Menke
@ 2018-08-14 14:58           ` Pablo Rodriguez
  2018-08-15  5:46             ` Use of context in lua (was: date calculated with currentdate plus n days) Jan U. Hasecke
  0 siblings, 1 reply; 9+ messages in thread
From: Pablo Rodriguez @ 2018-08-14 14:58 UTC (permalink / raw)
  To: ntg-context

On 08/14/2018 09:24 AM, Henri Menke wrote:
> On 14/08/18 17:29, Pablo Rodriguez wrote:
>> [...]
>> Where are those context.* Lua commands documented?
>>
>> I want to generate an xtable using Lua code, but I don’t know where to read.
> 
> They aren't documented because they are just the context commands.  You 
> can read more about how it works in 
> http://www.pragma-ade.nl/general/manuals/cld-mkiv.pdf

Many thanks for your reply, Henri.

I remember paging through the manual, it’s included in the distribution.

I rewrote your sample as (xtables are the only tables I know in ConTeXt):

    \starttext
    \startlua
    context.startxtable()
        context.startxrow()
         context.startxcell()
          context("Note 1")
         context.stopxcell()
         context.startxcell()
          context("Note 2")
         context.stopxcell()
        context.stopxrow()
        context.startxrow()
         context.startxcell()
          context("Note 3")
         context.stopxcell()
         context.startxcell()
          context("Note 4")
         context.stopxcell()
        context.stopxrow()
    context.stopxtable()
    \stoplua
    \stoptext

Many thanks for your help,

Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Use of context in lua (was: date calculated with currentdate plus n days)
  2018-08-14 14:58           ` Pablo Rodriguez
@ 2018-08-15  5:46             ` Jan U. Hasecke
  2018-08-15  6:45               ` Use of context in lua Henri Menke
  0 siblings, 1 reply; 9+ messages in thread
From: Jan U. Hasecke @ 2018-08-15  5:46 UTC (permalink / raw)
  To: ntg-context

On 14.08.2018 16:58, Pablo Rodriguez wrote:
> I rewrote your sample as (xtables are the only tables I know in ConTeXt):
> 
>     \starttext
>     \startlua
>     context.startxtable()
>         context.startxrow()
>          context.startxcell()
>           context("Note 1")
>          context.stopxcell()
>          context.startxcell()
>           context("Note 2")
>          context.stopxcell()
>         context.stopxrow()
>         context.startxrow()
>          context.startxcell()
>           context("Note 3")
>          context.stopxcell()
>          context.startxcell()
>           context("Note 4")
>          context.stopxcell()
>         context.stopxrow()
>     context.stopxtable()
>     \stoplua
>     \stoptext

Seeing this example I wonder if there is already an example taking a
csv-file and creating a table based on its content. I guess building
blocks are readfile, loops and setting the stop sign (; oder ,).

As I know a bit of Python, at least, I might be able to search for the
building blocks in the doku. ;-)

juh
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Use of context in lua
  2018-08-15  5:46             ` Use of context in lua (was: date calculated with currentdate plus n days) Jan U. Hasecke
@ 2018-08-15  6:45               ` Henri Menke
  0 siblings, 0 replies; 9+ messages in thread
From: Henri Menke @ 2018-08-15  6:45 UTC (permalink / raw)
  To: ntg-context



On 15/08/18 17:46, Jan U. Hasecke wrote:
> On 14.08.2018 16:58, Pablo Rodriguez wrote:
>> I rewrote your sample as (xtables are the only tables I know in ConTeXt):
>>
>>      \starttext
>>      \startlua
>>      context.startxtable()
>>          context.startxrow()
>>           context.startxcell()
>>            context("Note 1")
>>           context.stopxcell()
>>           context.startxcell()
>>            context("Note 2")
>>           context.stopxcell()
>>          context.stopxrow()
>>          context.startxrow()
>>           context.startxcell()
>>            context("Note 3")
>>           context.stopxcell()
>>           context.startxcell()
>>            context("Note 4")
>>           context.stopxcell()
>>          context.stopxrow()
>>      context.stopxtable()
>>      \stoplua
>>      \stoptext
> 
> Seeing this example I wonder if there is already an example taking a
> csv-file and creating a table based on its content. I guess building
> blocks are readfile, loops and setting the stop sign (; oder ,).

It already exists:
- Database module
   http://wiki.contextgarden.net/M-database
- handlecsv module
 
https://modules.contextgarden.net/cgi-bin/module.cgi/ruid=55907888/action=view/id=86

> 
> As I know a bit of Python, at least, I might be able to search for the
> building blocks in the doku. ;-)
> 
> juh
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
> 
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-08-15  6:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-13 15:19 date calculated with currentdate plus n days Jan U. Hasecke
2018-08-13 15:57 ` Pablo Rodriguez
2018-08-13 17:37   ` Jan U. Hasecke
2018-08-13 23:46     ` Henri Menke
2018-08-14  5:29       ` Pablo Rodriguez
2018-08-14  7:24         ` Henri Menke
2018-08-14 14:58           ` Pablo Rodriguez
2018-08-15  5:46             ` Use of context in lua (was: date calculated with currentdate plus n days) Jan U. Hasecke
2018-08-15  6:45               ` Use of context in lua Henri Menke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).