* Time_Zone-aware Day_of_Week ? @ 2015-07-13 13:26 Natasha Kerensikova 2015-07-13 16:45 ` Jeffrey R. Carter 2015-07-17 5:12 ` Vadim Godunko 0 siblings, 2 replies; 4+ messages in thread From: Natasha Kerensikova @ 2015-07-13 13:26 UTC (permalink / raw) Hello, I was implementing some human time formatting with the help of Ada 2005 standard package Ada.Calendar.Formatting, and realized I have an issue with the function Day_of_Week with regards to time zone. Everything else in Ada.Calendar.Formatting seems to support some user-defined time offset, but not Day_of_Week. Is there a particular reason for that? Moreover, the description in the ARM of the function is quite terse: "Returns the day of the week for Time. This is based on the Year, Month, and Day values of Time." However, all of Year, Month and Day functions do have the Time_Zone argument that Day_of_Week lacks. So which time offset is Day_of_Week supposed to use? Prying into GNAT's implementation, it seems to use standard system timezone, but can it be deduced from the ARM? Is there a workaround to still get a Day_of_Week result that is consistent with a user-given time offset? I'm currently leaning towards using Ada.Calendar.Arithmetic.Difference with a reference date, at midnight in the request time zone, but that feels a bit inelegant. Is there a better way of doing it? Thanks for your help, Natasha ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Time_Zone-aware Day_of_Week ? 2015-07-13 13:26 Time_Zone-aware Day_of_Week ? Natasha Kerensikova @ 2015-07-13 16:45 ` Jeffrey R. Carter 2015-07-16 17:07 ` brbarkstrom 2015-07-17 5:12 ` Vadim Godunko 1 sibling, 1 reply; 4+ messages in thread From: Jeffrey R. Carter @ 2015-07-13 16:45 UTC (permalink / raw) On 07/13/2015 06:26 AM, Natasha Kerensikova wrote: > > Moreover, the description in the ARM of the function is quite terse: > "Returns the day of the week for Time. This is based on the Year, Month, > and Day values of Time." Presumably the Year, Month, and Day returned by Ada.Calendar.Split. > However, all of Year, Month and Day functions do have the Time_Zone > argument that Day_of_Week lacks. So which time offset is Day_of_Week > supposed to use? I'd guess the time offset given by Ada.Calendar.Time_Zones.UTC_Time_Offset. PragmARC.Date_Handler.Day_Of_Week gives you the day of week of any Year, Month, and Day CE you care to give it, even for values of Year outside Ada.Calendar.Year_Number. It can also give you the day of week for any Ada.Calendar.Time, using the Year, Month, and Day returned by Ada.Calendar.Split. The PragmAda Reusable Components are at https://pragmada.x10hosting.com/pragmarc.htm -- Jeff Carter "He that hath no beard is less than a man." Much Ado About Nothing 132 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Time_Zone-aware Day_of_Week ? 2015-07-13 16:45 ` Jeffrey R. Carter @ 2015-07-16 17:07 ` brbarkstrom 0 siblings, 0 replies; 4+ messages in thread From: brbarkstrom @ 2015-07-16 17:07 UTC (permalink / raw) On Monday, July 13, 2015 at 12:45:48 PM UTC-4, Jeffrey R. Carter wrote: > On 07/13/2015 06:26 AM, Natasha Kerensikova wrote: > > > > Moreover, the description in the ARM of the function is quite terse: > > "Returns the day of the week for Time. This is based on the Year, Month, > > and Day values of Time." > > Presumably the Year, Month, and Day returned by Ada.Calendar.Split. > > > However, all of Year, Month and Day functions do have the Time_Zone > > argument that Day_of_Week lacks. So which time offset is Day_of_Week > > supposed to use? > > I'd guess the time offset given by Ada.Calendar.Time_Zones.UTC_Time_Offset. > > PragmARC.Date_Handler.Day_Of_Week gives you the day of week of any Year, Month, > and Day CE you care to give it, even for values of Year outside > Ada.Calendar.Year_Number. It can also give you the day of week for any > Ada.Calendar.Time, using the Year, Month, and Day returned by Ada.Calendar.Split. > > The PragmAda Reusable Components are at > > https://pragmada.x10hosting.com/pragmarc.htm > > -- > Jeff Carter > "He that hath no beard is less than a man." > Much Ado About Nothing > 132 Depending on the precision you need, it might be worth thinking about the difference between Civil Time (which uses Year, Month, Day, Hour, Minute, and Second) and International Atomic Time (TAI - due to French Standards). TAI tracks seconds and is directly related to GPS Time and one or two other variants. The standard reference for these different time systems is Seidelmann, P. K., 2006: Explanatory Supplement to the Astronomical Almanac, University Science Books, Sausalito, CA. If you need to calculate time differences frequently and want to avoid the unpleasantries of having to deal with errors associated with time zone inputs (or lack thereof), TAI is probably preferable. This may be important for Fourier analysis of time series, where the incomensurability of Civil Time can introduces errors into the frequency spectrum derived from the data. One satellite mission had to expend a great deal of effort to find that the lack of a common time basis caused some serious errors in their measurements of the Earth's reflection. Bruce B. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Time_Zone-aware Day_of_Week ? 2015-07-13 13:26 Time_Zone-aware Day_of_Week ? Natasha Kerensikova 2015-07-13 16:45 ` Jeffrey R. Carter @ 2015-07-17 5:12 ` Vadim Godunko 1 sibling, 0 replies; 4+ messages in thread From: Vadim Godunko @ 2015-07-17 5:12 UTC (permalink / raw) You can try Matreshka, it has some timezone and time formatting support. http://forge.ada-ru.org/matreshka ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-07-17 5:12 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2015-07-13 13:26 Time_Zone-aware Day_of_Week ? Natasha Kerensikova 2015-07-13 16:45 ` Jeffrey R. Carter 2015-07-16 17:07 ` brbarkstrom 2015-07-17 5:12 ` Vadim Godunko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox