• 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
Calculate Current Year Quarter with Time Zone Using AppleScriptObjC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Calculate Current Year Quarter with Time Zone Using AppleScriptObjC


  • Subject: Calculate Current Year Quarter with Time Zone Using AppleScriptObjC
  • From: Christopher Stone <email@hidden>
  • Date: Fri, 13 Jan 2017 23:17:37 -0600

Hey Folks,

I was looking to see if there was a better formula for calculating the year's quarter than what I had handy and found one that includes the time zone via AppleScriptObjC.

I thought I'd share.

--
Best Regards,
Chris

-------------------------------------------------------------------------------------------
# Auth: Christopher Stone { Heavy Lifting by vadian on StackOverflow } 
# dCre: 2017/01/13 22:45
# dMod: 2017/01/13 23:12
# Appl: Miscellaneous
# Task: Calculate Year Quarter from Current Date with Time Zone.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Calculate, @Year, @Quarter, @Current_Date, @Time_Zone, @Zone
-------------------------------------------------------------------------------------------
# date - AppleScript : get the current fiscal quarter for Ireland - Stack Overflow
# http://stackoverflow.com/questions/36515348/applescript-get-the-current-fiscal-quarter-for-ireland
-------------------------------------------------------------------------------------------
# List of valid time zone names:
# https://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/timezone.html
-------------------------------------------------------------------------------------------
use framework "Foundation"
-------------------------------------------------------------------------------------------

set currentCalendar to current application's NSCalendar's currentCalendar()
set theTimeZone to current application's NSTimeZone's timeZoneWithName:"US/Central"
set currentCalendar's timeZone to theTimeZone
set currentMonth to (currentCalendar's component:(current application's NSCalendarUnitMonth) fromDate:(current application's NSDate's |date|)) as integer
set currentQuarter to (((currentMonth - 1) div 3 + 1) as text) & "Q"

-------------------------------------------------------------------------------------------

(*

Some commonly used time zone names:

America/Chicago

Asia/Tokyo

Australia/Perth
Australia/Sydney

Etc/Greenwich
Etc/Universal 
Etc/UTC 
Etc/Zulu

Europe/Berlin
Europe/Dublin
Europe/London

US/Alaska 
US/Aleutian 
US/Arizona 
US/Central 
US/East-Indiana 
US/Eastern 
US/Hawaii 
US/Indiana-Starke 
US/Michigan 
US/Mountain 
US/Pacific 
US/Pacific-New 
US/Samoa 

Zulu 

*)


 _______________________________________________
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

  • Follow-Ups:
    • Re: Calculate Current Year Quarter with Time Zone Using AppleScriptObjC
      • From: Deivy Petrescu <email@hidden>
    • Re: Calculate Current Year Quarter with Time Zone Using AppleScriptObjC
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: Finder Renaming Unpleasant Surprise
  • Next by Date: Re: Calculate Current Year Quarter with Time Zone Using AppleScriptObjC
  • Previous by thread: Re: Coercing ligatures to expanded characters
  • Next by thread: Re: Calculate Current Year Quarter with Time Zone Using AppleScriptObjC
  • Index(es):
    • Date
    • Thread