Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Ctod() weirdness
Message
De
14/08/2015 16:05:03
 
 
À
14/08/2015 12:04:30
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01623085
Message ID:
01623420
Vues:
36
>>>>>Time for an extremely stupid question -- is there any particular reason why you have
>>>>>SET CENTURY TO 20
>>>>>instead of
>>>>>SET CENTURY TO 19
>>>>
>>>>Thanks. It seems that this was the solution to the riddle. Setting it to 19, I get the correct date. Why the setting is so, I have no idea - Visual ProMatrix set it automatically. (Nor do I have any clear idea why, according to Visual FoxPro, I should set century to 19, when we are actually in the 21st century...)
>>>
>>>It's zero based.
>>>
>>>IOW, the XX century is "all the years written as 19nn, including 2000 but excluding 1900", so this "set century to 19" is actually "set the hundreds part of the year to 19". The word century here is a complete misnomer.
>>
>>Even with these non-standard definitions, I would expect to have to specify the "century" as 20, since that's the "century" we are in, i.e., the current year starts with 20. But when I do that, I get a year that starts with 21 - so, a year in the 21st "century" according to the logic you explained. However, perhaps the ROLLOVER somehow adds one more digit to the century.
>
>Keep in mind that these things were written from the perspective of Y2K craze. So everyone had calendars with years beginning with 19 in their sights, and in that context it probably made sense.
>
>Now add 20 years to the context.

Considering that the specification was written from the perspective of someone who was living in the latter half of a century, it's written from "what made sense" at that time from his/her perspective. The default value "19" comes about because that's what the first two digits were at the time when the specification was thought up. In the perspective of someone living in the latter half of a century would think this would be sensible:
IF nYear > 100 THEN
    * Assume century is already 4-digit value, no need to 
ELSE
    IF nYear < nRollover THEN
        nYear = ((nCentury+1) * 100) + nYear
    ELSE
        nYear = (nCentury * 100) + nYear
    ENDIF
ENDIF
...
Someone from the perspective of being in the earlier part of the century might look at the above logic might think that the logic is backwards.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform