How to access the DateTime object

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to access the DateTime object

steinbil

Hi everyone

This seems like it should be rather basic, but I cannot for the life of me figure out how to access the DateTime object, or rather the variables has.

I’ve read a couple of different versions of the Manuscript Reference, but it doesn’t describe how to access this object, just that it exists and which variables it has.

I tried a simple test:

Sibelius.MessageBox(DateTime.LongDate)

But it tells me

Field DateTime not found

So I tried accessing it from the Sibelius-object

Sibelius.MessageBox(Sibelius.DateTime.LongDate)

and now it says

Cannot get field DateTime

What is it that I’m missing here?



Best regards
Steinar Refsdal


_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
Reply | Threaded
Open this post in threaded view
|

Re: How to access the DateTime object

Martin Marris

Try this:

 

Sibelius.MessageBox(Sibelius.CurrentDateLong);

 

Martin

 

From: Plugin-dev [mailto:[hidden email]] On Behalf Of Steinar Refsdal
Sent: Wednesday, February 28, 2018 16:04
To: A mailing list for Sibelius plug-in developers
Subject: [Plugin-dev] How to access the DateTime object

 

Hi everyone

This seems like it should be rather basic, but I cannot for the life of me figure out how to access the DateTime object, or rather the variables has.

I’ve read a couple of different versions of the Manuscript Reference, but it doesn’t describe how to access this object, just that it exists and which variables it has.

I tried a simple test:

Sibelius.MessageBox(DateTime.LongDate)

But it tells me

Field DateTime not found

So I tried accessing it from the Sibelius-object

Sibelius.MessageBox(Sibelius.DateTime.LongDate)

and now it says

Cannot get field DateTime

What is it that I’m missing here?

 

 

Best regards

Steinar Refsdal


_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
Reply | Threaded
Open this post in threaded view
|

Re: How to access the DateTime object

steinbil

Thanks Martin!

So to sum it up (for other slow learners like myself):

Sibelius.CurrentDate returns the DateTime object for the current date and time on the local computer. So by accessing Sibelius.CurrentDate.Hours and the other variables like Minutes, Seconds, Year, Month and Day of month – I managed to get all the variables I needed to create my custom file naming scheme for my export plugins.



Best regards
Steinar Refsdal

On 28 February 2018 at 22:11:48, Martin Marris ([hidden email]) wrote:

Sibelius.MessageBox(Sibelius.CurrentDateLong);


_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com
Reply | Threaded
Open this post in threaded view
|

Re: How to access the DateTime object

Bob Zawalich-3
In reply to this post by Martin Marris

I note that Sibelius.CurrentDateLong returns a string, not a DateTime object. Sibelius.CurrentDate gives you a DateTime object which you can get various formats from.

 

 

Here are some examples. You can get  DateTime objects from File objects as well as the current date

 

                        case(6) // ' Current Date Short'

                        {

                                    dateTime = Sibelius.CurrentDate;

                                    strData = dateTime.ShortDate;

 

                                    score.@strInfoField = strData;

                                    trace('  current short date is ' & strData);

                        }

 

                        case(7) // ' Current Date Long'

                        {

                                    dateTime = Sibelius.CurrentDate;

                                    strData = dateTime.LongDate;

 

                                    score.@strInfoField = strData;

                                    trace('  current long date is ' & strData);

                        }

 

                        case(8) // 'Current Time'

                        {

                                    strData = FormatTime(Sibelius.CurrentDate);

 

                                    score.@strInfoField = strData;

                                    trace('  current time is ' & strData);

                        }

 

                        case(9) // ' Modified Date'

                        {

                                    str = score.FileName;

                                    file = Sibelius.GetFile(str);

                                    dateTime = file.ModificationDate;

                                    //trace('Mod date: ' & dateTime);

                                    strData = dateTime.ShortDate;

 

                                    score.@strInfoField = strData;

                                    trace('  score modified date is ' & strData);

                        }

 

                        case(10) // 'Modified Time'

                        {

                                    str = score.FileName;

                                    file = Sibelius.GetFile(str);

                                    dateTime = file.ModificationDate;

                                    //trace('Mod time: ' & dateTime);

 

                                    strData = FormatTime(dateTime);

 

                                    score.@strInfoField = strData;

                                    trace('  score modified time is ' & strData);

                        }

 

From: Plugin-dev [mailto:[hidden email]] On Behalf Of Martin Marris
Sent: Wednesday, February 28, 2018 1:11 PM
To: 'A mailing list for Sibelius plug-in developers' <[hidden email]>
Subject: Re: [Plugin-dev] How to access the DateTime object

 

Try this:

 

Sibelius.MessageBox(Sibelius.CurrentDateLong);

 

Martin

 

From: Plugin-dev [[hidden email]] On Behalf Of Steinar Refsdal
Sent: Wednesday, February 28, 2018 16:04
To: A mailing list for Sibelius plug-in developers
Subject: [Plugin-dev] How to access the DateTime object

 

Hi everyone

This seems like it should be rather basic, but I cannot for the life of me figure out how to access the DateTime object, or rather the variables has.

I’ve read a couple of different versions of the Manuscript Reference, but it doesn’t describe how to access this object, just that it exists and which variables it has.

I tried a simple test:

Sibelius.MessageBox(DateTime.LongDate)

But it tells me

Field DateTime not found

So I tried accessing it from the Sibelius-object

Sibelius.MessageBox(Sibelius.DateTime.LongDate)

and now it says

Cannot get field DateTime

What is it that I’m missing here?

 

 

Best regards

Steinar Refsdal


_______________________________________________
Plugin-dev mailing list
[hidden email]
http://lists.avid.com/mailman/listinfo/plugin-dev_lists.avid.com