priPrinter: Date formating - priPrinter

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Date formating

#1 User is offline   zachroberts 

  • Member
  • PipPip
  • Group: Senior Members
  • Posts: 17
  • Joined: 19-January 16

Posted 07 March 2016 - 06:45 PM

Hi how can you set the date format to mm,dd,yy?

Thanks,
Zach
0

#2 User is offline   Alex 

  • Administrator
  • Group: Administrators
  • Posts: 238
  • Joined: 28-February 10
  • LocationHungary

Posted 11 March 2016 - 08:58 PM

You may need to format text manually, where do you want to do that?
0

#3 User is offline   zachroberts 

  • Member
  • PipPip
  • Group: Senior Members
  • Posts: 17
  • Joined: 19-January 16

Posted 14 March 2016 - 04:34 PM

View PostAlex, on 11 March 2016 - 08:58 PM, said:

You may need to format text manually, where do you want to do that?

Right now it is using the date option when you make a template. Can you format the date with scripting?

Thanks,
Zach
0

#4 User is offline   Alex 

  • Administrator
  • Group: Administrators
  • Posts: 238
  • Joined: 28-February 10
  • LocationHungary

Posted 14 March 2016 - 10:23 PM

Generating text from date may look in the following way:
    local d=Date();
    m.text= d.day.tostring() +"/"+d.month.tostring() +"/"+ d.year.tostring();

or
m.text= d.day.tostring() +"/"+d.month.tostring() +"/"+ (d.year%100).tostring();

if you prefer two digits year.

Full script may look in the following way:

if(layout.GetNumSheets())
{

// create markup

local m = layout.GetMarkupById(103);

if(!m){
    m = layout.CreateMarkup("string");
    m.id=103;
    local f=m.font;
    f.height=20;
    f.name="Verdana";
    m.font=f;
    m.outline=true;
    m.pos=Point(0.5,0.95);
    m.color=Color(50,100,150);
    m.alpha=0.5;

}
// update text
if(m)
{  
    if(0)
{
	// standard appearance
	m.text="$(Time) $(Date)"
}else{
	// very custom appearance
	    local d=Date();
        //m.text= d.day.tostring() +"/"+d.month.tostring() +"/"+ d.year.tostring();
		m.text= d.day.tostring() +"/"+d.month.tostring() +"/"+ (d.year%100).tostring();
	}
}
}

0

#5 User is offline   zachroberts 

  • Member
  • PipPip
  • Group: Senior Members
  • Posts: 17
  • Joined: 19-January 16

Posted 21 March 2016 - 07:00 PM

View PostAlex, on 14 March 2016 - 10:23 PM, said:

Generating text from date may look in the following way:
    local d=Date();
    m.text= d.day.tostring() +"/"+d.month.tostring() +"/"+ d.year.tostring();

or
m.text= d.day.tostring() +"/"+d.month.tostring() +"/"+ (d.year%100).tostring();

if you prefer two digits year.

Full script may look in the following way:

if(layout.GetNumSheets())
{

// create markup

local m = layout.GetMarkupById(103);

if(!m){
    m = layout.CreateMarkup("string");
    m.id=103;
    local f=m.font;
    f.height=20;
    f.name="Verdana";
    m.font=f;
    m.outline=true;
    m.pos=Point(0.5,0.95);
    m.color=Color(50,100,150);
    m.alpha=0.5;

}
// update text
if(m)
{  
    if(0)
{
	// standard appearance
	m.text="$(Time) $(Date)"
}else{
	// very custom appearance
	    local d=Date();
        //m.text= d.day.tostring() +"/"+d.month.tostring() +"/"+ d.year.tostring();
		m.text= d.day.tostring() +"/"+d.month.tostring() +"/"+ (d.year%100).tostring();
	}
}
}


Thanks that works for the year but how can i get the month and day to print out in a 2 digit format as well? i tried adding %100 behind month and day but that didnt work the month was still printing 3 instead of 03

I need to get it to print out as mm/dd/yy for example. 03/21/2016
0

#6 User is offline   zachroberts 

  • Member
  • PipPip
  • Group: Senior Members
  • Posts: 17
  • Joined: 19-January 16

Posted 21 March 2016 - 07:54 PM

View Postzachroberts, on 21 March 2016 - 07:00 PM, said:

Thanks that works for the year but how can i get the month and day to print out in a 2 digit format as well? i tried adding %100 behind month and day but that didnt work the month was still printing 3 instead of 03

I need to get it to print out as mm/dd/yy for example. 03/21/2016

so i meant 03/21/16 in above example
0

#7 User is offline   Alex 

  • Administrator
  • Group: Administrators
  • Posts: 238
  • Joined: 28-February 10
  • LocationHungary

Posted 22 March 2016 - 10:31 PM

Then you can use something like that:

Day or month may be converted to string and if length of string is less than 2 characters we may put leading zero.

  local day=d.day.tostring();
  if(day.len()<2)day="0"+day;

  local month=d.month.tostring();
  if(month.len()<2)month="0"+month;

  m.text="Date:"+day+"/"+month+"/"+d.year;

0

#8 User is offline   zachroberts 

  • Member
  • PipPip
  • Group: Senior Members
  • Posts: 17
  • Joined: 19-January 16

Posted 24 March 2016 - 04:32 PM

View PostAlex, on 22 March 2016 - 10:31 PM, said:

Then you can use something like that:

Day or month may be converted to string and if length of string is less than 2 characters we may put leading zero.

  local day=d.day.tostring();
  if(day.len()<2)day="0"+day;

  local month=d.month.tostring();
  if(month.len()<2)month="0"+month;

  m.text="Date:"+day+"/"+month+"/"+d.year;


Works great! Thanks!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users