Returns the current date and time as a serial Julian date and time. <span align="right" style="background-color:99FF99"><strong>Excel: NOW</strong></span>

View versions (1)

Interface

#include <codecogs/units/time/now.h>

using namespace Units::Time;

Returns the current date and time as a serial Julian date, with time expressed as a fraction of the overall (24hr day), i.e.

date = Julian\ Days + \frac{3600 hours + 60 minutes + seconds}{24 *3600}
(1)

where hours, minutes and seconds are derived from the local system time. This function then uses summertime to make appropriate adjustment for summer daylight saving.

Example 1

#include <stdio.h>
#include <codecogs/units/time/now.h>
#include <codecogs/units/date/day.h>
#include <codecogs/units/date/month_str.h>
#include <codecogs/units/date/month.h>
#include <codecogs/units/date/year.h>
#include <codecogs/units/time/hour.h>
#include <codecogs/units/time/minute.h>
#include <codecogs/units/time/second.h>

using namespace Units::Time;
using namespace Units::Date;

int main()
{
  double a=now(st_UK);
  printf("\n\n Is is now the %d %s %04d %2d:%02d:%02d",
         day((int)a), month_str(month((int)a)), year((int)a),
         hour(a), minute(a), second(a));
  return 0;
}

Parameters

Region
is the location or country for which the existence of summer time is required, see summerTimeRegion for codes. For ease, there are two additional options that can be specified:
Blank
  • st_None : Applies no summer time alterations.
  • st_Local: Applies the default local summer time alterations as defined by the C function localtime. This uses country setting of the underlying operating system to detect when summer daylight saving should be applied. We can not guarantee the operation of localtime, so we generally recommend that this option is not used - except were you do not have doubts about the location the program is being run from.
GPL Licence — free for non commercial use. See Licence details.