DateTime objects in many programming languages describe an instant in time, expressed as a date and time of day.

learn more… | top users | synonyms

13
votes
1answer
68 views

It's Friday! - Zeller's Congruence Revisited

A couple of date-related questions have come up recently, and on both occasions I have been taken back to my 'early' days where one of my first forays in to programming involved implementing Zeller's ...
5
votes
1answer
160 views

Logging with date in Java

I write my log messages in JTextArea. Each message should have a time added. I created a following method: ...
13
votes
3answers
3k views

Is it Friday yet?

This is the first program that I have written in my C++ saga that I actually think is useful. The description for this assignment is kinda long and mundane though: Write a program that inputs a ...
5
votes
3answers
80 views

Summing some datum for requests in each domain that fall in a date range

I have a LINQ query which works fine. I am however very interested to understand if this can be written in a more optimum way... ...
1
vote
1answer
65 views

Least suprising extension methods for DateTime to NATO date-time group

I have the following code to get a NATO date-time group for a DateTime. I usually need Zulu-Time or from a specific time zone. Is it clear what those methods are providing? If want to parse a NATO dtg ...
7
votes
1answer
68 views

Filter out date records which don't fall within or span a date range

I have records which have specific time spans. The need is to select records which adhere to the following three rules (read them as or conditions) concerning a ...
4
votes
1answer
52 views

Fast regex to extract strings before and after a time

I want to get text1 and text2 by splitting time format Text1 10:24:02 Text2 Of the ...
7
votes
2answers
345 views

Find the number of working days between two dates inclusively

The objective is to find the number of working days (days spanning from Monday to Friday) between two given dates inclusively. ...
8
votes
0answers
53 views

Chrono-like clock with different epoch (from 1.1. 2000)

The following will by my simple helper, that should behave just like std::chrono::system_clock but with the epoch being 1.1. 2000, that I can easily cast durations ...
10
votes
5answers
607 views

Function for checking leap years

As part of one of my AP Computer Science labs, I was required to write a function to determine whether a year was a leap year or not. Included as comments are a few reasons why I did things, as well ...
6
votes
2answers
62 views

Leap year functionality in Ruby and JavaScript

I did a line-by-line translation and am wondering if the JavaScript code looks idiomatic. Original Ruby code: ...
2
votes
2answers
69 views

Determining the next payment renewal date

I am not very good a JavaScript, surely not date manipulation, but I hacked together the script below with the purpose to determine the next payment renewal date based on a start date and payment ...
5
votes
1answer
38 views

Using a TSV text file and map for a Q&A program

The program outputs a menu asking for a new question or to ask a question. If you ask a question, it will search a .tsv text file for the question and return the answer. It will then check a map that ...
3
votes
2answers
79 views

Designing a Time class [closed]

Problem Statement: 1. Design a class TIME which stores hour, minute and second. The class should have the methods to support the following: User may give the time value in 24-hour format. User may ...
1
vote
1answer
28 views

Observing PEP maximum line size, particularly when formatting localized timestamps

I have this function that I use to publish a message but I need to do this long conversion for time and date. Maybe there's a better way to convert it to make smaller. Otherwise I'm stuck with this ...
7
votes
3answers
62 views

Parsing dates from an OCR application

I wrote this code to parse dates from the output of the OCR, which means that the obtained date can be literally anything, so I put some restrictions in place: Date is the the format of: ...
7
votes
3answers
71 views

Calendar Print Method

I'm currently learning Ruby and need help in editing code to be more idiomatic. I have the method below I could use some pointers on how to make more "Ruby" :-) ...
1
vote
2answers
104 views

Weekly fee calculation

I have the following query. Its execution took 15 min and it's too much slow. Is there a way to optimize it? ...
6
votes
1answer
90 views

Dict of names and birth dates which prints with age at birthday of current year

As a beginner (Learn Python the Hard Way), I've set myself this exercise with classes and it works but looks very inelegant to me. I'm trying to write classes which could be re-used in other code. ...
1
vote
1answer
32 views

Using Regexp to select the date from a string [closed]

I have a string with date details with time, but I would like to show the day information alone. For that, I use the regexp to select the date. Can anyone tell me the regexp, and if what is used is ...
3
votes
1answer
45 views

Python Long UTC DateTime String

now = datetime.datetime.utcnow() now.strftime('%d %b %Y %I:%M:%S.%f')[:-3] + now.strftime(' %p') Is there a cleaner solution for this? I don't want the extra ...
4
votes
2answers
195 views

Converting numeric (month/day/year) date inputs to regular format (month day, year)

I'd really appreciate some general formatting/style/performance tips, as well as any ways I could improve this code in general that I wrote for an assignment (title) that's due at the end of the week. ...
4
votes
1answer
88 views

Cron expression validator for Apache Quartz

Not too long ago, I had to create a cron expression for a route in Apache Camel. I had a bit of a struggle to find the right expression. So I made a small program to output the n next valid dates ...
2
votes
1answer
62 views

How to send an email every half an hour if certain condition is met during that period?

I have my below method which will be called every one minute from the background thread. In my below code, if my unauthorizedCount and ...
5
votes
1answer
106 views

Extension methods for Daylight Savings Time dates

Just wondering if anyone had any suggestions for improvements. I created these extension methods so it's easier to get the start and end dates of Daylight Savings Time from the ...
3
votes
1answer
58 views

Read CSV with 3 columns and group some elements

I have a csv with 3 columns (date, name, number) and it is about 20K rows long. I want to create a dictionary keyed by date whose value is a dictionary of ...
6
votes
3answers
309 views

Time to Next Departure

I am trying to find out how many minutes that are remaining until the next train will departure, based on the current system time in Java. I am so far not familiar with the many aspects of Java, but ...
3
votes
3answers
314 views

Parsing and formatting a time two ways (perfectionistic approach)

I'm still not satisfied by the readability of the code. The wanted behavior which would be self descriptive would sound like: "I've two fields; one is for the date and one for the hour. This two ...
2
votes
1answer
62 views

Using datetime in order to name files

I have a script that makes use of datetime in order to name files. Only business days (Mon - Fri) are used. Here is my part of the code that finds the last ...
3
votes
2answers
272 views

Converting seconds to hours, minutes and seconds

The following question was taken from Absolute Java 5th ed. by Walter Savitch: Write a program that outputs the number of hours, minutes, and seconds that corresponds to 50,391 total seconds. The ...
10
votes
4answers
283 views

Ugly optimized caching of SimpleDateFormat

Concerning the optimization of this simple function String formatDate(String format, Locale locale, Date date) {...} formatting a ...
6
votes
3answers
407 views

Shutdown Delay Program

I wrote this program a while back that would allow me to set a delay, say 3 hours, and when the delay had expired, my PC would turn off. The purpose of it was so I didn't have to leave my PC on all ...
10
votes
1answer
85 views

Labor percentage and wages from clock in/out and sales records

I'm developing a PHP function for calculating labor percentage (labor cost/sales) accounting for daily and weekly overtime rules, if applicable, based on the payroll period; the wages for each ...
3
votes
2answers
66 views

Cycling time trials

It would be helpful to know where I could improve the style of it, so it follows the style guide better, and also any ways I could compact it - especially at the end, where I have added items to a ...
5
votes
2answers
79 views

DateTime internal representation to FILETIME

Here is a routine I put together to convert SQL Server's internal DateTime representation (BINARY(8)) to a ...
3
votes
4answers
324 views

Need help to optimise my C# code

I have a section of my code that seems to take a while during processing. Basically rawArray contains ~1.5 million rows and ...
3
votes
1answer
60 views

Structural design of a Date and Time classes [closed]

I have two classes named Date.class and an enum class Time. I have declared these class like ...
2
votes
1answer
71 views

Bitwise operation to get the weekday name

The function days_name receive a val (string) corresponding to weekdays in hexadecimal. ...
0
votes
3answers
99 views

Linq query performs poor according to performance analyzer in VS2012

I've a Linq query that performs poorly: ...
4
votes
3answers
88 views

Validate parameters within a range

Function to use several blocks of if:elif:else: that all take slightly different conditional statements. I'm trying to format integers into a 2 digit string, ...
4
votes
1answer
42 views

Calling PHP file using Ajax

I like to know if there will be any performance issue if an xmlhttp object is created every time. For example, in the below code: ...
7
votes
2answers
139 views

Getting a date range

I'm just trying to be more pythonic in my coding style and was wondering if this is a good way to get a list of seven days leading up to and including endDate: ...
3
votes
4answers
577 views

Code Kata - Berlin Clock

To improve my programming style, I have been writing solutions for popular code katas. I have written a partial solution for the [Berlin Clock kata][1]. Can anyone critique the code and suggest ...
10
votes
4answers
514 views

Integer seconds to formated string mm:ss

I have a String like "Time left (XX)" or "You need stay here for (XX)" and int as second. I use those two variables to format ...
5
votes
2answers
224 views

Calculating months elapsed since a given date

I am using traceview and DDMS to analyse my operation. The following is my traceview as displayed in DDMS: According to the above, the LoaderClass.months() ...
3
votes
2answers
230 views

Checking whether a given timestamp is more than two weeks old

I am trying to see whether a given timestamp is more than two weeks old or not. If it is two weeks old, then print out "Hello" and if it is not more than two weeks old then print out "World". I have ...
6
votes
2answers
102 views

Berlin clock kata in Elixir

I'm starting with Elixir and as exercise I wrote the Berlin Clock kata: The clock is made up of 5 rows. On the very top of the clock is a lamp that blinks to show the seconds. It turns on for one ...
19
votes
6answers
2k views

Average time to first answer

Just trying out my T-SQL foo. Wrote a script to get the average time (in seconds) to first answer for a specified language. ...
3
votes
2answers
80 views

Convert international datestring to ISO-format

The function below takes a datestring in the form d-mmm-yyyy and converts it to ISO date format (yyyy-mm-dd). Delimiters may be hyphen, space or /, and Dutch or ...
3
votes
2answers
62 views

Date Comparison Script

The University Library where I work is in the process of redesigned our home page. One of the features we wish to include is a widget to display the current hours. Unfortunately for a variety of ...