• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Time anomaly
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Time anomaly


  • Subject: Re: Time anomaly
  • From: Axel Luttgens <email@hidden>
  • Date: Mon, 29 Oct 2012 18:57:58 +0100

Le 28 oct. 2012 à 22:44, Shane Stanley a écrit :

> [...]
> The whole idea of just changing the month is fraught.
> [...]

Agreed: expecting the ability to change a date's month (or more generally, any component of a date) to go beyond the construction of *valid* date objects is likely to quickly lead to ill-defined operations.

For example, let's consider:

	set D to date "mardi 31 janvier 2012 00:00:00" -- ie 2012-01-31

Throughout the thread, it has (at least implicitly) been assumed that:

	set month of D to 2

should do something "clever" such as, for example, add 31 days to D and yield:

	date "vendredi 2 mars 2012 00:00:00" -- ie 2012-03-02

But why 31 days? Because january has 31 days?
(moreover, why is it then likely that nobody would suggest to add 62 days to D when setting D's month to 3 instead of 2? or to add 30 days when setting the month of 2012-04-31 to 5?)

And why not have considered another "clever" behavior in the first place, such as keeping the resulting date's within the bounds of the targeted month? And thus set D to:

	date "mercredi 29 février 2012 00:00:00" -- ie 2012-02-29

Now, let's set the month back to 1; in the first case, one would get:

	date "lundi 2 janvier 2012 00:00:00" -- ie 2012-01-02

and in the second case:

	date "dimanche 29 janvier 2012 00:00:00" -- ie 2012-01-29

Clearly, neither is very satisfactory as soon as one considers the whole effect of:

	set D to date "mardi 31 janvier 2012 00:00:00" -- ie 2012-01-31
	set month of D to 2 -- expect AppleScript to provide some semantics
	set month of D to 1 -- ask AppleScript to build a valid date object

Perhaps the really "clever" behavior would be to raise an error when the user tries to set a date's component to an invalid value.

Axel




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden


References: 
 >Re: Time anomaly (From: Miguel Torikachvili <email@hidden>)
 >Re: Time anomaly (From: Ron Hunsinger <email@hidden>)
 >Re: Time anomaly (From: Thomas Fischer <email@hidden>)
 >Re: Time anomaly (From: Michelle Steiner <email@hidden>)
 >Re: Time anomaly (From: Jon Pugh <email@hidden>)
 >Re: Time anomaly (From: Shane Stanley <email@hidden>)

  • Prev by Date: glyphs missing indesign cs4/cs5
  • Next by Date: FileMaker Pro 12.0v3 - unable to launch or activate w/o open file dialog popping up
  • Previous by thread: Re: Time anomaly
  • Next by thread: Re: Time anomaly
  • Index(es):
    • Date
    • Thread